2019-11-21 04:06:16 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-10 09:45:23 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::Git::RemoteRepository, :seed_helper do
|
2018-12-23 02:34:35 -05:00
|
|
|
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
|
2019-12-12 07:07:33 -05:00
|
|
|
|
2017-11-10 09:45:23 -05:00
|
|
|
subject { described_class.new(repository) }
|
|
|
|
|
2017-12-07 10:33:30 -05:00
|
|
|
describe '#empty?' do
|
2017-11-10 09:45:23 -05:00
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
where(:repository, :result) do
|
2018-12-23 02:34:35 -05:00
|
|
|
Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') | false
|
|
|
|
Gitlab::Git::Repository.new('default', 'does-not-exist.git', '', 'group/project') | true
|
2017-11-10 09:45:23 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
2017-12-07 10:33:30 -05:00
|
|
|
it { expect(subject.empty?).to eq(result) }
|
2017-11-10 09:45:23 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#commit_id' do
|
|
|
|
it 'returns an OID if the revision exists' do
|
|
|
|
expect(subject.commit_id('v1.0.0')).to eq('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is nil when the revision does not exist' do
|
|
|
|
expect(subject.commit_id('does-not-exist')).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#branch_exists?' do
|
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
where(:branch, :result) do
|
|
|
|
'master' | true
|
|
|
|
'does-not-exist' | false
|
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
it { expect(subject.branch_exists?(branch)).to eq(result) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#same_repository?' do
|
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
where(:other_repository, :result) do
|
2018-12-23 02:34:35 -05:00
|
|
|
repository | true
|
|
|
|
Gitlab::Git::Repository.new(repository.storage, repository.relative_path, '', 'group/project') | true
|
|
|
|
Gitlab::Git::Repository.new('broken', TEST_REPO_PATH, '', 'group/project') | false
|
|
|
|
Gitlab::Git::Repository.new(repository.storage, 'wrong/relative-path.git', '', 'group/project') | false
|
|
|
|
Gitlab::Git::Repository.new('broken', 'wrong/relative-path.git', '', 'group/project') | false
|
2017-11-10 09:45:23 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
it { expect(subject.same_repository?(other_repository)).to eq(result) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|