diff options
Diffstat (limited to 'spec/lib/gitlab/shell_spec.rb')
-rw-r--r-- | spec/lib/gitlab/shell_spec.rb | 62 |
1 files changed, 19 insertions, 43 deletions
diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb index a17e9a31212..79ad1c0b43f 100644 --- a/spec/lib/gitlab/shell_spec.rb +++ b/spec/lib/gitlab/shell_spec.rb @@ -310,18 +310,18 @@ describe Gitlab::Shell do let(:disk_path) { "#{project.disk_path}.git" } it 'returns true when the command succeeds' do - expect(gitlab_shell.exists?(project.repository_storage, disk_path)).to be(true) + expect(TestEnv.storage_dir_exists?(project.repository_storage, disk_path)).to be(true) expect(gitlab_shell.remove_repository(project.repository_storage, project.disk_path)).to be(true) - expect(gitlab_shell.exists?(project.repository_storage, disk_path)).to be(false) + expect(TestEnv.storage_dir_exists?(project.repository_storage, disk_path)).to be(false) end it 'keeps the namespace directory' do gitlab_shell.remove_repository(project.repository_storage, project.disk_path) - expect(gitlab_shell.exists?(project.repository_storage, disk_path)).to be(false) - expect(gitlab_shell.exists?(project.repository_storage, project.disk_path.gsub(project.name, ''))).to be(true) + expect(TestEnv.storage_dir_exists?(project.repository_storage, disk_path)).to be(false) + expect(TestEnv.storage_dir_exists?(project.repository_storage, project.disk_path.gsub(project.name, ''))).to be(true) end end @@ -332,18 +332,18 @@ describe Gitlab::Shell do old_path = project2.disk_path new_path = "project/new_path" - expect(gitlab_shell.exists?(project2.repository_storage, "#{old_path}.git")).to be(true) - expect(gitlab_shell.exists?(project2.repository_storage, "#{new_path}.git")).to be(false) + expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{old_path}.git")).to be(true) + expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{new_path}.git")).to be(false) expect(gitlab_shell.mv_repository(project2.repository_storage, old_path, new_path)).to be_truthy - expect(gitlab_shell.exists?(project2.repository_storage, "#{old_path}.git")).to be(false) - expect(gitlab_shell.exists?(project2.repository_storage, "#{new_path}.git")).to be(true) + expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{old_path}.git")).to be(false) + expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{new_path}.git")).to be(true) end it 'returns false when the command fails' do expect(gitlab_shell.mv_repository(project2.repository_storage, project2.disk_path, '')).to be_falsy - expect(gitlab_shell.exists?(project2.repository_storage, "#{project2.disk_path}.git")).to be(true) + expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{project2.disk_path}.git")).to be(true) end end @@ -403,56 +403,32 @@ describe Gitlab::Shell do it 'creates a namespace' do subject.add_namespace(storage, "mepmep") - expect(subject.exists?(storage, "mepmep")).to be(true) + expect(TestEnv.storage_dir_exists?(storage, "mepmep")).to be(true) end end - describe '#exists?' do - context 'when the namespace does not exist' do + describe '#repository_exists?' do + context 'when the repository does not exist' do it 'returns false' do - expect(subject.exists?(storage, "non-existing")).to be(false) + expect(subject.repository_exists?(storage, "non-existing.git")).to be(false) end end - context 'when the namespace exists' do + context 'when the repository exists' do it 'returns true' do - subject.add_namespace(storage, "mepmep") + project = create(:project, :repository, :legacy_storage) - expect(subject.exists?(storage, "mepmep")).to be(true) + expect(subject.repository_exists?(storage, project.repository.disk_path + ".git")).to be(true) end end end - describe '#repository_exists?' do - context 'when the storage path does not exist' do - subject { described_class.new.repository_exists?(storage, "non-existing.git") } - - it { is_expected.to be_falsey } - end - - context 'when the repository does not exist' do - let(:project) { create(:project, :repository, :legacy_storage) } - - subject { described_class.new.repository_exists?(storage, "#{project.repository.disk_path}-some-other-repo.git") } - - it { is_expected.to be_falsey } - end - - context 'when the repository exists' do - let(:project) { create(:project, :repository, :legacy_storage) } - - subject { described_class.new.repository_exists?(storage, "#{project.repository.disk_path}.git") } - - it { is_expected.to be_truthy } - end - end - describe '#remove' do it 'removes the namespace' do subject.add_namespace(storage, "mepmep") subject.rm_namespace(storage, "mepmep") - expect(subject.exists?(storage, "mepmep")).to be(false) + expect(TestEnv.storage_dir_exists?(storage, "mepmep")).to be(false) end end @@ -461,8 +437,8 @@ describe Gitlab::Shell do subject.add_namespace(storage, "mepmep") subject.mv_namespace(storage, "mepmep", "2mep") - expect(subject.exists?(storage, "mepmep")).to be(false) - expect(subject.exists?(storage, "2mep")).to be(true) + expect(TestEnv.storage_dir_exists?(storage, "mepmep")).to be(false) + expect(TestEnv.storage_dir_exists?(storage, "2mep")).to be(true) end end end |