diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/tasks/gitlab/db_rake_spec.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/tasks/gitlab/db_rake_spec.rb')
-rw-r--r-- | spec/tasks/gitlab/db_rake_spec.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb index c4623061944..08ca6c32b49 100644 --- a/spec/tasks/gitlab/db_rake_spec.rb +++ b/spec/tasks/gitlab/db_rake_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rake' -RSpec.describe 'gitlab:db namespace rake task' do +RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do before :all do Rake.application.rake_require 'active_record/railties/databases' Rake.application.rake_require 'tasks/seed_fu' @@ -306,7 +306,7 @@ RSpec.describe 'gitlab:db namespace rake task' do let(:all_migrations) { [double('migration1', version: 1), pending_migration] } let(:pending_migration) { double('migration2', version: 2) } let(:filename) { Gitlab::Database::Migrations::Instrumentation::STATS_FILENAME } - let!(:directory) { Dir.mktmpdir } + let(:result_dir) { Dir.mktmpdir } let(:observations) { %w[some data] } before do @@ -316,19 +316,17 @@ RSpec.describe 'gitlab:db namespace rake task' do allow(instrumentation).to receive(:observe).and_yield - allow(Dir).to receive(:mkdir) - allow(File).to receive(:exist?).with(directory).and_return(false) - stub_const('Gitlab::Database::Migrations::Instrumentation::RESULT_DIR', directory) + stub_const('Gitlab::Database::Migrations::Instrumentation::RESULT_DIR', result_dir) end after do - FileUtils.rm_rf([directory]) + FileUtils.rm_rf(result_dir) end - it 'fails when the directory already exists' do - expect(File).to receive(:exist?).with(directory).and_return(true) + it 'creates result directory when one does not exist' do + FileUtils.rm_rf(result_dir) - expect { subject }.to raise_error(/Directory exists/) + expect { subject }.to change { Dir.exist?(result_dir) }.from(false).to(true) end it 'instruments the pending migration' do @@ -346,7 +344,7 @@ RSpec.describe 'gitlab:db namespace rake task' do it 'writes observations out to JSON file' do subject - expect(File.read(File.join(directory, filename))).to eq(observations.to_json) + expect(File.read(File.join(result_dir, filename))).to eq(observations.to_json) end end |