diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 18:08:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 18:08:05 +0300 |
commit | f78257cbddd711e18cbce93ad740a4aa0acac347 (patch) | |
tree | 7f018abe3ce1c0010879cc480f348a35e616fabb /spec/support | |
parent | f500600a43b531e2e7a5858b74bd35312b02c349 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
2 files changed, 42 insertions, 12 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/config/inheritable_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/config/inheritable_shared_examples.rb index 556d81133bc..95772b1774a 100644 --- a/spec/support/shared_examples/lib/gitlab/config/inheritable_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/config/inheritable_shared_examples.rb @@ -53,7 +53,7 @@ RSpec.shared_examples 'with inheritable CI config' do let(:deps) do if inheritable_key - double('deps', inheritable_key => inheritable, '[]' => unspecified) + double('deps', "#{inheritable_key}_entry" => inheritable, '[]' => unspecified) else inheritable end @@ -68,7 +68,7 @@ RSpec.shared_examples 'with inheritable CI config' do it 'does inherit value' do expect(inheritable).to receive('[]').with(entry_key).and_return(specified) - entry.compose!(deps) + entry.send(:inherit!, deps) expect(entry[entry_key]).to eq(specified) end @@ -86,7 +86,7 @@ RSpec.shared_examples 'with inheritable CI config' do expect do # we ignore exceptions as `#overwrite_entry` # can raise exception on duplicates - entry.compose!(deps) rescue described_class::InheritError + entry.send(:inherit!, deps) rescue described_class::InheritError end.not_to change { entry[entry_key] } end end @@ -94,7 +94,7 @@ RSpec.shared_examples 'with inheritable CI config' do context 'when inheritable does not specify' do it 'does not inherit value' do - entry.compose!(deps) + entry.send(:inherit!, deps) expect(entry[entry_key]).to be_a( Gitlab::Config::Entry::Undefined) diff --git a/spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb b/spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb index f222dff60ab..6f83f52d54b 100644 --- a/spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb +++ b/spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb @@ -2,7 +2,10 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| let(:project_repository_double) { double(:repository) } + let!(:project_repository_checksum) { project.repository.checksum } + let(:repository_double) { double(:repository) } + let(:repository_checksum) { repository.checksum } before do # Default stub for non-specified params @@ -19,15 +22,16 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| context 'when the move succeeds', :clean_gitlab_redis_shared_state do before do - allow(project_repository_double) - .to receive(:fetch_repository_as_mirror) + allow(project_repository_double).to receive(:fetch_repository_as_mirror) .with(project.repository.raw) .and_return(true) + allow(project_repository_double).to receive(:checksum) + .and_return(project_repository_checksum) - allow(repository_double) - .to receive(:fetch_repository_as_mirror) - .with(repository.raw) - .and_return(true) + allow(repository_double).to receive(:fetch_repository_as_mirror) + .with(repository.raw).and_return(true) + allow(repository_double).to receive(:checksum) + .and_return(repository_checksum) end it "moves the project and its #{repository_type} repository to the new storage and unmarks the repository as read only" do @@ -37,8 +41,9 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| old_repository_path = repository.full_path - subject.execute('test_second_storage') + result = subject.execute('test_second_storage') + expect(result[:status]).to eq(:success) expect(project).not_to be_repository_read_only expect(project.repository_storage).to eq('test_second_storage') expect(gitlab_shell.repository_exists?('default', old_project_repository_path)).to be(false) @@ -87,13 +92,38 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| it 'unmarks the repository as read-only without updating the repository storage' do allow(project_repository_double).to receive(:fetch_repository_as_mirror) .with(project.repository.raw).and_return(true) + allow(project_repository_double).to receive(:checksum) + .and_return(project_repository_checksum) allow(repository_double).to receive(:fetch_repository_as_mirror) .with(repository.raw).and_return(false) expect(GitlabShellWorker).not_to receive(:perform_async) - subject.execute('test_second_storage') + result = subject.execute('test_second_storage') + + expect(result[:status]).to eq(:error) + expect(project).not_to be_repository_read_only + expect(project.repository_storage).to eq('default') + end + end + + context "when the checksum of the #{repository_type} repository does not match" do + it 'unmarks the repository as read-only without updating the repository storage' do + allow(project_repository_double).to receive(:fetch_repository_as_mirror) + .with(project.repository.raw).and_return(true) + allow(project_repository_double).to receive(:checksum) + .and_return(project_repository_checksum) + + allow(repository_double).to receive(:fetch_repository_as_mirror) + .with(repository.raw).and_return(true) + allow(repository_double).to receive(:checksum) + .and_return('not matching checksum') + + expect(GitlabShellWorker).not_to receive(:perform_async) + + result = subject.execute('test_second_storage') + expect(result[:status]).to eq(:error) expect(project).not_to be_repository_read_only expect(project.repository_storage).to eq('default') end |