Skip to content
Snippets Groups Projects
Commit d0c2a6fdc6ca authored by Gabriel Mazetto's avatar Gabriel Mazetto
Browse files

Use LoggingHelper to log warning instead of `warn`.

Added expectations methods to make it easier to test
parent 619bc7974276
No related branches found
No related tags found
2 merge requests!51Validate shift of Heptapod 0.25 to oldstable series,!44GitLab 14.0
......@@ -35,7 +35,7 @@
def check_consul_is_enabled
return if Services.enabled?('consul')
warn('Patroni is enabled but Consul seems to be disabled. Patroni requires Consul to be enabled.')
LoggingHelper.warning('Patroni is enabled but Consul seems to be disabled. Patroni requires Consul to be enabled.')
end
def postgresql_setting(key)
......
......@@ -585,7 +585,9 @@
end
it 'expects a warning to be printed' do
expect { chef_run }.to output(/Patroni is enabled but Consul seems to be disabled/).to_stderr
chef_run
expect_logged_warning(/Patroni is enabled but Consul seems to be disabled/)
end
end
end
......@@ -20,6 +20,7 @@
config.run_all_when_everything_filtered = true
config.include(GitlabSpec::Macros)
config.include(GitlabSpec::Expectations)
config.disable_monkey_patching!
end
# frozen_string_literal: true
module GitlabSpec
module Expectations
# Expect a note to be logged with the specified message
#
# @param [String] message
# @see LoggingHelper.warning
def expect_logged_note(message)
expect(LoggingHelper.messages).to include(kind: :note, message: message)
end
# Expect a deprecation to be logged with the specified message
#
# @param [String] message
# @see LoggingHelper.warning
def expect_logged_deprecation(message)
expect(LoggingHelper.messages).to include(kind: :deprecation, message: message)
end
# Expect a removal to be logged with the specified message
#
# @param [String] message
# @see LoggingHelper.warning
def expect_logged_removal(message)
expect(LoggingHelper.messages).to include(kind: :removal, message: message)
end
# Expect a warning to be logged with the specified message
#
# @param [String] message
# @see LoggingHelper.warning
def expect_logged_warning(message)
expect(LoggingHelper.messages).to include(kind: :warning, message: message)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment