summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/gitaly_client/ref_service_spec.rb')
-rw-r--r--spec/lib/gitlab/gitaly_client/ref_service_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
index d308612ef31..2e37c98a591 100644
--- a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
@@ -190,6 +190,22 @@ RSpec.describe Gitlab::GitalyClient::RefService do
client.tags(sort_by: 'name_asc')
end
end
+
+ context 'with pagination option' do
+ it 'sends a correct find_all_tags message' do
+ expected_pagination = Gitaly::PaginationParameter.new(
+ limit: 5,
+ page_token: 'refs/tags/v1.0.0'
+ )
+
+ expect_any_instance_of(Gitaly::RefService::Stub)
+ .to receive(:find_all_tags)
+ .with(gitaly_request_with_params(pagination_params: expected_pagination), kind_of(Hash))
+ .and_return([])
+
+ client.tags(pagination_params: { limit: 5, page_token: 'refs/tags/v1.0.0' })
+ end
+ end
end
describe '#branch_names_contains_sha' do
@@ -252,6 +268,26 @@ RSpec.describe Gitlab::GitalyClient::RefService do
end
end
+ describe '#list_refs' do
+ it 'sends a list_refs message' do
+ expect_any_instance_of(Gitaly::RefService::Stub)
+ .to receive(:list_refs)
+ .with(gitaly_request_with_params(patterns: ['refs/heads/']), kind_of(Hash))
+ .and_call_original
+
+ client.list_refs
+ end
+
+ it 'accepts a patterns argument' do
+ expect_any_instance_of(Gitaly::RefService::Stub)
+ .to receive(:list_refs)
+ .with(gitaly_request_with_params(patterns: ['refs/tags/']), kind_of(Hash))
+ .and_call_original
+
+ client.list_refs([Gitlab::Git::TAG_REF_PREFIX])
+ end
+ end
+
describe '#pack_refs' do
it 'sends a pack_refs message' do
expect_any_instance_of(Gitaly::RefService::Stub)
@@ -262,4 +298,19 @@ RSpec.describe Gitlab::GitalyClient::RefService do
client.pack_refs
end
end
+
+ describe '#find_refs_by_oid' do
+ let(:oid) { project.repository.commit.id }
+
+ it 'sends a find_refs_by_oid message' do
+ expect_any_instance_of(Gitaly::RefService::Stub)
+ .to receive(:find_refs_by_oid)
+ .with(gitaly_request_with_params(sort_field: 'refname', oid: oid, limit: 1), kind_of(Hash))
+ .and_call_original
+
+ refs = client.find_refs_by_oid(oid: oid, limit: 1)
+
+ expect(refs.to_a).to eq([Gitlab::Git::BRANCH_REF_PREFIX + project.repository.root_ref])
+ end
+ end
end