diff --git a/spec/chef/package/libraries/omnibus_helper_spec.rb b/spec/chef/package/libraries/omnibus_helper_spec.rb index aa0f09214720162a8ee71852e5add9c5ab668e33_c3BlYy9jaGVmL3BhY2thZ2UvbGlicmFyaWVzL29tbmlidXNfaGVscGVyX3NwZWMucmI=..224ffc46af509d7a8fd67319b6a859a28e15cd1b_c3BlYy9jaGVmL3BhY2thZ2UvbGlicmFyaWVzL29tbmlidXNfaGVscGVyX3NwZWMucmI= 100644 --- a/spec/chef/package/libraries/omnibus_helper_spec.rb +++ b/spec/chef/package/libraries/omnibus_helper_spec.rb @@ -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 diff --git a/spec/chef/recipes/database_migrations_spec.rb b/spec/chef/recipes/database_migrations_spec.rb index aa0f09214720162a8ee71852e5add9c5ab668e33_c3BlYy9jaGVmL3JlY2lwZXMvZGF0YWJhc2VfbWlncmF0aW9uc19zcGVjLnJi..224ffc46af509d7a8fd67319b6a859a28e15cd1b_c3BlYy9jaGVmL3JlY2lwZXMvZGF0YWJhc2VfbWlncmF0aW9uc19zcGVjLnJi 100644 --- a/spec/chef/recipes/database_migrations_spec.rb +++ b/spec/chef/recipes/database_migrations_spec.rb @@ -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 diff --git a/spec/chef/recipes/letsencrypt_spec.rb b/spec/chef/recipes/letsencrypt_spec.rb index aa0f09214720162a8ee71852e5add9c5ab668e33_c3BlYy9jaGVmL3JlY2lwZXMvbGV0c2VuY3J5cHRfc3BlYy5yYg==..224ffc46af509d7a8fd67319b6a859a28e15cd1b_c3BlYy9jaGVmL3JlY2lwZXMvbGV0c2VuY3J5cHRfc3BlYy5yYg== 100644 --- a/spec/chef/recipes/letsencrypt_spec.rb +++ b/spec/chef/recipes/letsencrypt_spec.rb @@ -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 diff --git a/spec/libraries/deprecations_spec.rb b/spec/libraries/deprecations_spec.rb index aa0f09214720162a8ee71852e5add9c5ab668e33_c3BlYy9saWJyYXJpZXMvZGVwcmVjYXRpb25zX3NwZWMucmI=..224ffc46af509d7a8fd67319b6a859a28e15cd1b_c3BlYy9saWJyYXJpZXMvZGVwcmVjYXRpb25zX3NwZWMucmI= 100644 --- a/spec/libraries/deprecations_spec.rb +++ b/spec/libraries/deprecations_spec.rb @@ -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