debian-mirror-gitlab/spec/lib/gitlab/git/remote_repository_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
2 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Git::RemoteRepository, :seed_helper do
2019-03-02 22:35:43 +05:30
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
2020-01-01 13:55:28 +05:30
2018-03-17 18:26:18 +05:30
subject { described_class.new(repository) }
describe '#empty?' do
using RSpec::Parameterized::TableSyntax
where(:repository, :result) do
2019-03-02 22:35:43 +05:30
Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') | false
Gitlab::Git::Repository.new('default', 'does-not-exist.git', '', 'group/project') | true
2018-03-17 18:26:18 +05:30
end
with_them do
it { expect(subject.empty?).to eq(result) }
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
2019-03-02 22:35:43 +05:30
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
2018-03-17 18:26:18 +05:30
end
with_them do
it { expect(subject.same_repository?(other_repository)).to eq(result) }
end
end
end