diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 21:07:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 21:07:51 +0300 |
commit | 6cae2159b8ce1e84fad48f3dbd5368995cbd87b1 (patch) | |
tree | 46d6b7cbd78d72fe5dcb5d6b1ed973b30deadc71 /spec/tasks | |
parent | 84f9f0cb8137637708a41152347e7754c1e9fb83 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tasks')
-rw-r--r-- | spec/tasks/gitlab/db/lock_writes_rake_spec.rb | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/spec/tasks/gitlab/db/lock_writes_rake_spec.rb b/spec/tasks/gitlab/db/lock_writes_rake_spec.rb index 24a2c0a48f7..9d54241aa7f 100644 --- a/spec/tasks/gitlab/db/lock_writes_rake_spec.rb +++ b/spec/tasks/gitlab/db/lock_writes_rake_spec.rb @@ -14,7 +14,9 @@ RSpec.describe 'gitlab:db:lock_writes', :reestablished_active_record_base, featu end let(:table_locker) { instance_double(Gitlab::Database::TablesLocker) } - let(:logger) { instance_double(Logger) } + let(:logger) { instance_double(Logger, level: nil) } + let(:dry_run) { false } + let(:verbose) { false } before do allow(Logger).to receive(:new).with($stdout).and_return(logger) @@ -24,7 +26,10 @@ RSpec.describe 'gitlab:db:lock_writes', :reestablished_active_record_base, featu end shared_examples "call table locker" do |method| + let(:log_level) { verbose ? Logger::INFO : Logger::WARN } + it "creates TablesLocker with dry run set and calls #{method}" do + expect(logger).to receive(:level=).with(log_level) expect(table_locker).to receive(method) run_rake_task("gitlab:db:#{method}") @@ -57,6 +62,30 @@ RSpec.describe 'gitlab:db:lock_writes', :reestablished_active_record_base, featu include_examples "call table locker", :lock_writes end + + context 'when environment sets VERBOSE to true' do + let(:verbose) { true } + + before do + stub_env('VERBOSE', 'true') + end + + include_examples "call table locker", :lock_writes + end + + context 'when environment sets VERBOSE to false' do + let(:verbose) { false } + + before do + stub_env('VERBOSE', 'false') + end + + include_examples "call table locker", :lock_writes + end + + context 'when environment does not define VERBOSE' do + include_examples "call table locker", :lock_writes + end end describe 'unlock_writes' do @@ -71,8 +100,6 @@ RSpec.describe 'gitlab:db:lock_writes', :reestablished_active_record_base, featu end context 'when environment sets DRY_RUN to false' do - let(:dry_run) { false } - before do stub_env('DRY_RUN', 'false') end @@ -81,9 +108,31 @@ RSpec.describe 'gitlab:db:lock_writes', :reestablished_active_record_base, featu end context 'when environment does not define DRY_RUN' do - let(:dry_run) { false } - include_examples "call table locker", :unlock_writes end + + context 'when environment sets VERBOSE to true' do + let(:verbose) { true } + + before do + stub_env('VERBOSE', 'true') + end + + include_examples "call table locker", :lock_writes + end + + context 'when environment sets VERBOSE to false' do + let(:verbose) { false } + + before do + stub_env('VERBOSE', 'false') + end + + include_examples "call table locker", :lock_writes + end + + context 'when environment does not define VERBOSE' do + include_examples "call table locker", :lock_writes + end end end |