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

Rewrite test expectations to use new `expect_logged_:something`

parent aa0f0921
No related branches found
No related tags found
3 merge requests!51Validate shift of Heptapod 0.25 to oldstable series,!47Making Heptapod 0.25 the new stable in Omnibus,!45GitLab 14.2
......@@ -151,5 +151,4 @@
it 'detects deprecated OS correctly' do
allow_any_instance_of(Ohai::System).to receive(:data).and_return({ "platform" => "raspbian", "platform_version" => "8.0" })
expect(LoggingHelper).to receive(:deprecation).with(/Your OS, raspbian-8.0, will be deprecated soon/)
OmnibusHelper.is_deprecated_os?
......@@ -155,4 +154,6 @@
OmnibusHelper.is_deprecated_os?
expect_logged_deprecation(/Your OS, raspbian-8.0, will be deprecated soon/)
end
it 'does not detects valid OS as deprecated' do
......@@ -178,6 +179,5 @@
end
it 'detects deprecated config correctly' do
expect(LoggingHelper).to receive(:deprecation)
.with(/Specifying Praefect storage nodes as an array is deprecated/)
subject.is_deprecated_praefect_config?
......@@ -183,5 +183,5 @@
subject.is_deprecated_praefect_config?
expect_logged_deprecation(/Specifying Praefect storage nodes as an array is deprecated/)
end
end
......@@ -260,6 +260,5 @@
it 'attempts to remove the file' do
expect(FileUtils).to receive(:rm_f).with('/etc/gitlab/initial_root_password')
expect(LoggingHelper).to receive(:note).with('Found old initial root password file at /etc/gitlab/initial_root_password and deleted it.')
described_class.cleanup_root_password_file
......@@ -264,5 +263,7 @@
described_class.cleanup_root_password_file
expect_logged_note('Found old initial root password file at /etc/gitlab/initial_root_password and deleted it.')
end
end
......@@ -273,6 +274,5 @@
it 'does not attempt to remove the file' do
expect(FileUtils).not_to receive(:rm_f).with('/etc/gitlab/initial_root_password')
expect(LoggingHelper).not_to receive(:note).with('Found old initial root password file at /etc/gitlab/initial_root_password and deleted it.')
described_class.cleanup_root_password_file
......@@ -277,5 +277,7 @@
described_class.cleanup_root_password_file
expect_logged_note('Found old initial root password file at /etc/gitlab/initial_root_password and deleted it.')
end
end
end
......@@ -320,5 +322,5 @@
NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
EOS
expect(LoggingHelper).to receive(:note).with(msg)
described_class.new(converge_config.node).print_root_account_details
......@@ -324,5 +326,5 @@
described_class.new(converge_config.node).print_root_account_details
expect_logged_note(msg)
end
end
......@@ -346,5 +348,5 @@
NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
EOS
expect(LoggingHelper).to receive(:note).with(msg)
described_class.new(converge_config.node).print_root_account_details
......@@ -350,5 +352,5 @@
described_class.new(converge_config.node).print_root_account_details
expect_logged_note(msg)
end
end
......@@ -366,5 +368,4 @@
it 'writes initial root password to /etc/gitlab/initial_root_password' do
subject = described_class.new(converge_config.node)
expect(subject).to receive(:write_root_password)
......@@ -370,4 +371,3 @@
expect(subject).to receive(:write_root_password)
expect(LoggingHelper).to receive(:note).with(%r{Password stored to /etc/gitlab/initial_root_password})
subject.print_root_account_details
......@@ -372,5 +372,7 @@
subject.print_root_account_details
expect_logged_note(%r{Password stored to /etc/gitlab/initial_root_password})
end
end
......@@ -386,6 +388,5 @@
subject = described_class.new(chef_run.node)
expect(subject).to receive(:write_root_password)
expect(LoggingHelper).to receive(:note).with(%r{Password stored to /etc/gitlab/initial_root_password})
subject.print_root_account_details
......@@ -390,5 +391,7 @@
subject.print_root_account_details
expect_logged_note(%r{Password stored to /etc/gitlab/initial_root_password})
end
end
......@@ -451,5 +454,5 @@
allow(ENV).to receive(:[]).and_call_original
allow(ENV).to receive(:[]).with('LC_ALL').and_return('en_SG ISO-8859-1')
expect(LoggingHelper).to receive(:warning).with("Environment variable LC_ALL specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
described_class.check_locale
......@@ -455,5 +458,5 @@
described_class.check_locale
expect_logged_warning("Environment variable LC_ALL specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
end
end
......@@ -466,5 +469,5 @@
it 'raises warning when LC_CTYPE is non-UTF-8' do
allow(ENV).to receive(:[]).with('LC_CTYPE').and_return('en_SG ISO-8859-1')
expect(LoggingHelper).to receive(:warning).with("Environment variable LC_CTYPE specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
described_class.check_locale
......@@ -470,5 +473,5 @@
described_class.check_locale
expect_logged_warning("Environment variable LC_CTYPE specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
end
end
......@@ -482,5 +485,5 @@
it 'raises warning when LC_COLLATE is non-UTF-8' do
allow(ENV).to receive(:[]).with('LC_COLLATE').and_return('en_SG ISO-8859-1')
expect(LoggingHelper).to receive(:warning).with("Environment variable LC_COLLATE specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
described_class.check_locale
......@@ -486,5 +489,5 @@
described_class.check_locale
expect_logged_warning("Environment variable LC_COLLATE specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
end
end
......@@ -503,5 +506,5 @@
it 'raises warning when LANG is non-UTF-8' do
allow(ENV).to receive(:[]).with('LANG').and_return('en_SG ISO-8859-1')
expect(LoggingHelper).to receive(:warning).with("Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
described_class.check_locale
......@@ -507,5 +510,5 @@
described_class.check_locale
expect_logged_warning("Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
end
end
......@@ -518,5 +521,5 @@
it 'raises warning when LANG is non-UTF-8' do
allow(ENV).to receive(:[]).with('LANG').and_return('en_SG ISO-8859-1')
expect(LoggingHelper).to receive(:warning).with("Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
described_class.check_locale
......@@ -522,5 +525,5 @@
described_class.check_locale
expect_logged_warning("Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
end
end
......@@ -531,5 +534,5 @@
end
it 'does not raise a warning even if LANG is not UTF-8' do
expect(LoggingHelper).not_to receive(:warning).with("Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
described_class.check_locale
......@@ -535,5 +538,5 @@
described_class.check_locale
expect_logged_warning("Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.")
end
end
end
......
......@@ -41,6 +41,5 @@
expect(migration_block).to notify('ruby_block[check remote PG version]').to(:run)
expect(chef_run.ruby_block('check remote PG version').should_skip?(:run)).to be_falsey
expect(LoggingHelper).to receive(:warning).with(/Support for PostgreSQL 11 has been removed/)
chef_run.ruby_block('check remote PG version').block.call
......@@ -45,5 +44,7 @@
chef_run.ruby_block('check remote PG version').block.call
expect_logged_warning(/Support for PostgreSQL 11 has been removed/)
end
end
......
......@@ -156,5 +156,4 @@
end
it 'warns that we do not setup automatic renewal' do
expect(LoggingHelper).to receive(:warning).with(/does not setup/)
chef_run.ruby_block('display_le_message').block.call
......@@ -160,4 +159,6 @@
chef_run.ruby_block('display_le_message').block.call
expect_logged_warning(/does not setup/)
end
end
end
......
......@@ -207,5 +207,4 @@
config = { 'monitoring' => { 'test' => 'test-value' } }
config['prometheus'] = Gitlab::Deprecations::NodeAttribute.new(config['monitoring'], "config['prometheus']", "config['monitoring']")
expect(LoggingHelper).to receive(:deprecation).with(/Accessing config\['prometheus'\] is deprecated/)
expect(config['prometheus']['test']).to eq('test-value')
......@@ -211,7 +210,8 @@
expect(config['prometheus']['test']).to eq('test-value')
expect_logged_deprecation(/Accessing config\['prometheus'\] is deprecated/)
end
it 'Logs deprecations for passed variables and proxies to new Proc if provided' do
config = { 'monitoring' => { 'test' => 'test-value' } }
config['prometheus'] = Gitlab::Deprecations::NodeAttribute.new(proc { config['monitoring'] }, "config['prometheus']", "config['monitoring']")
......@@ -212,8 +212,7 @@
end
it 'Logs deprecations for passed variables and proxies to new Proc if provided' do
config = { 'monitoring' => { 'test' => 'test-value' } }
config['prometheus'] = Gitlab::Deprecations::NodeAttribute.new(proc { config['monitoring'] }, "config['prometheus']", "config['monitoring']")
expect(LoggingHelper).to receive(:deprecation).with(/Accessing config\['prometheus'\] is deprecated/)
expect(config['prometheus']['test']).to eq('test-value')
......@@ -219,4 +218,5 @@
expect(config['prometheus']['test']).to eq('test-value')
expect_logged_deprecation(/Accessing config\['prometheus'\] is deprecated/)
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