summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/gitaly_client
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-18 13:16:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-18 13:16:36 +0000
commit311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch)
tree07e7870bca8aed6d61fdcc810731c50d2c40af47 /spec/lib/gitlab/gitaly_client
parent27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff)
downloadgitlab-ce-311b0269b4eb9839fa63f80c8d7a58f32b8138a0.tar.gz
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'spec/lib/gitlab/gitaly_client')
-rw-r--r--spec/lib/gitlab/gitaly_client/commit_service_spec.rb37
-rw-r--r--spec/lib/gitlab/gitaly_client/ref_service_spec.rb51
2 files changed, 81 insertions, 7 deletions
diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
index 554a91f2bc5..d8e397dd6f3 100644
--- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
@@ -112,15 +112,38 @@ RSpec.describe Gitlab::GitalyClient::CommitService do
let(:from) { 'master' }
let(:to) { Gitlab::Git::EMPTY_TREE_ID }
- it 'sends an RPC request' do
- request = Gitaly::CommitsBetweenRequest.new(
- repository: repository_message, from: from, to: to
- )
+ context 'with between_commits_via_list_commits enabled' do
+ before do
+ stub_feature_flags(between_commits_via_list_commits: true)
+ end
- expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:commits_between)
- .with(request, kind_of(Hash)).and_return([])
+ it 'sends an RPC request' do
+ request = Gitaly::ListCommitsRequest.new(
+ repository: repository_message, revisions: ["^" + from, to], reverse: true
+ )
+
+ expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:list_commits)
+ .with(request, kind_of(Hash)).and_return([])
- described_class.new(repository).between(from, to)
+ described_class.new(repository).between(from, to)
+ end
+ end
+
+ context 'with between_commits_via_list_commits disabled' do
+ before do
+ stub_feature_flags(between_commits_via_list_commits: false)
+ end
+
+ it 'sends an RPC request' do
+ request = Gitaly::CommitsBetweenRequest.new(
+ repository: repository_message, from: from, to: to
+ )
+
+ expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:commits_between)
+ .with(request, kind_of(Hash)).and_return([])
+
+ described_class.new(repository).between(from, to)
+ end
end
end
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