diff options
Diffstat (limited to 'spec/services/projects')
-rw-r--r-- | spec/services/projects/fork_service_spec.rb | 7 | ||||
-rw-r--r-- | spec/services/projects/update_repository_storage_service_spec.rb | 24 |
2 files changed, 17 insertions, 14 deletions
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb index 4e5f10b3947..731febe75b3 100644 --- a/spec/services/projects/fork_service_spec.rb +++ b/spec/services/projects/fork_service_spec.rb @@ -311,9 +311,10 @@ describe Projects::ForkService do fork_before_move = fork_project(project) # Stub everything required to move a project to a Gitaly shard that does not exist - stub_storage_settings('test_second_storage' => { 'path' => 'tmp/tests/second_storage' }) - allow_any_instance_of(Gitlab::Git::Repository).to receive(:fetch_repository_as_mirror).and_return(true) - allow_any_instance_of(Gitlab::Git::Repository).to receive(:checksum).and_return(::Gitlab::Git::BLANK_SHA) + stub_storage_settings('test_second_storage' => { 'path' => TestEnv::SECOND_STORAGE_PATH }) + allow_any_instance_of(Gitlab::Git::Repository).to receive(:replicate) + allow_any_instance_of(Gitlab::Git::Repository).to receive(:checksum) + .and_return(::Gitlab::Git::BLANK_SHA) Projects::UpdateRepositoryStorageService.new(project).execute('test_second_storage') fork_after_move = fork_project(project) diff --git a/spec/services/projects/update_repository_storage_service_spec.rb b/spec/services/projects/update_repository_storage_service_spec.rb index 2e9a4626abb..106a639ba28 100644 --- a/spec/services/projects/update_repository_storage_service_spec.rb +++ b/spec/services/projects/update_repository_storage_service_spec.rb @@ -32,8 +32,8 @@ describe Projects::UpdateRepositoryStorageService do project.repository.path_to_repo end - expect(project_repository_double).to receive(:fetch_repository_as_mirror) - .with(project.repository.raw).and_return(true) + expect(project_repository_double).to receive(:replicate) + .with(project.repository.raw) expect(project_repository_double).to receive(:checksum) .and_return(checksum) @@ -49,16 +49,18 @@ describe Projects::UpdateRepositoryStorageService do context 'when the project is already on the target storage' do it 'bails out and does nothing' do - expect do - subject.execute(project.repository_storage) - end.to raise_error(described_class::RepositoryAlreadyMoved) + result = subject.execute(project.repository_storage) + + expect(result[:status]).to eq(:error) + expect(result[:message]).to match(/repository and source have the same storage/) end end context 'when the move fails' do it 'unmarks the repository as read-only without updating the repository storage' do - expect(project_repository_double).to receive(:fetch_repository_as_mirror) - .with(project.repository.raw).and_return(false) + expect(project_repository_double).to receive(:replicate) + .with(project.repository.raw) + .and_raise(Gitlab::Git::CommandError) expect(GitlabShellWorker).not_to receive(:perform_async) result = subject.execute('test_second_storage') @@ -71,8 +73,8 @@ describe Projects::UpdateRepositoryStorageService do context 'when the checksum does not match' do it 'unmarks the repository as read-only without updating the repository storage' do - expect(project_repository_double).to receive(:fetch_repository_as_mirror) - .with(project.repository.raw).and_return(true) + expect(project_repository_double).to receive(:replicate) + .with(project.repository.raw) expect(project_repository_double).to receive(:checksum) .and_return('not matching checksum') expect(GitlabShellWorker).not_to receive(:perform_async) @@ -89,8 +91,8 @@ describe Projects::UpdateRepositoryStorageService do let!(:pool) { create(:pool_repository, :ready, source_project: project) } it 'leaves the pool' do - expect(project_repository_double).to receive(:fetch_repository_as_mirror) - .with(project.repository.raw).and_return(true) + expect(project_repository_double).to receive(:replicate) + .with(project.repository.raw) expect(project_repository_double).to receive(:checksum) .and_return(checksum) |