Commit 7710235e authored by Gabriel Mazetto's avatar Gabriel Mazetto

Added specs for failures in Geo repository sync and update services

parent c5c2af93
...@@ -207,20 +207,20 @@ describe Geo::RepositorySyncService, services: true do ...@@ -207,20 +207,20 @@ describe Geo::RepositorySyncService, services: true do
end end
context 'when Gitlab::Shell::Error is raised' do context 'when Gitlab::Shell::Error is raised' do
let(:project) { create(:project_empty_repo) } let(:project) { create(:empty_project) }
it 'rescues exception' do it 'rescues exception' do
allow(subject).to receive(:fetch_project_repository).and_raise(Gitlab::Shell::Error) expect(subject).to receive(:fetch_project_repository).and_raise(Gitlab::Shell::Error)
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
end end
end end
context 'when Gitlab::Git::Repository::NoRepository is raised' do context 'when Gitlab::Git::Repository::NoRepository is raised' do
let(:project) { create(:project_empty_repo) } let(:project) { create(:empty_project) }
it 'rescues exception and fires after_create hook' do it 'rescues exception and fires after_create hook' do
allow(subject).to receive(:fetch_project_repository).and_raise(Gitlab::Git::Repository::NoRepository) expect(subject).to receive(:fetch_project_repository).and_raise(Gitlab::Git::Repository::NoRepository)
expect_any_instance_of(Repository).to receive(:after_create) expect_any_instance_of(Repository).to receive(:after_create)
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
......
...@@ -50,10 +50,17 @@ describe Geo::RepositoryUpdateService, services: true do ...@@ -50,10 +50,17 @@ describe Geo::RepositoryUpdateService, services: true do
subject.execute subject.execute
end end
it 'does not raise exception when git failures occurs' do it 'rescues Gitlab::Shell::Error failures' do
expect(project.repository).to receive(:fetch_geo_mirror).and_raise(Gitlab::Shell::Error) expect(project.repository).to receive(:fetch_geo_mirror).and_raise(Gitlab::Shell::Error)
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
end end
it 'rescues Gitlab::Git::Repository::NoRepository failures and fires after_create hook' do
expect(project.repository).to receive(:fetch_geo_mirror).and_raise(Gitlab::Git::Repository::NoRepository)
expect_any_instance_of(Repository).to receive(:after_create)
expect { subject.execute }.not_to raise_error
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment