diff options
author | Stan Hu <stanhu@gmail.com> | 2018-05-08 23:56:46 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-05-09 12:00:37 +0300 |
commit | 9bf4ae3d86c4bee53bfdff74c3b1d6c055e66fac (patch) | |
tree | 4f3ca4e656f2a0e47054235ad72753587b336662 /spec | |
parent | b026cf783fc971a1d25660def692e99baec750ce (diff) |
Merge branch '5750-backport-checksum-git-commanderror-exit-status-128' into 'master'
Raise InvalidRepository error for non-valid git repositories
See merge request gitlab-org/gitlab-ce!18594
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/git/repository_spec.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 9f091975959..cce84276fe3 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -2275,7 +2275,22 @@ describe Gitlab::Git::Repository, seed_helper: true do expect(empty_repo.checksum).to eq '0000000000000000000000000000000000000000' end - it 'raises a no repository exception when there is no repo' do + it 'raises Gitlab::Git::Repository::InvalidRepository error for non-valid git repo' do + FileUtils.rm_rf(File.join(storage_path, 'non-valid.git')) + + system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --bare #{TEST_REPO_PATH} non-valid.git), + chdir: SEED_STORAGE_PATH, + out: '/dev/null', + err: '/dev/null') + + File.truncate(File.join(storage_path, 'non-valid.git/HEAD'), 0) + + non_valid = described_class.new('default', 'non-valid.git', '') + + expect { non_valid.checksum }.to raise_error(Gitlab::Git::Repository::InvalidRepository) + end + + it 'raises Gitlab::Git::Repository::NoRepository error when there is no repo' do broken_repo = described_class.new('default', 'a/path.git', '') expect { broken_repo.checksum }.to raise_error(Gitlab::Git::Repository::NoRepository) |