Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
commit0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch)
tree4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/lib/gitlab/gitaly_client
parent744144d28e3e7fddc117924fef88de5d9674fe4c (diff)
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/lib/gitlab/gitaly_client')
-rw-r--r--spec/lib/gitlab/gitaly_client/blob_service_spec.rb23
-rw-r--r--spec/lib/gitlab/gitaly_client/commit_service_spec.rb35
-rw-r--r--spec/lib/gitlab/gitaly_client/ref_service_spec.rb63
-rw-r--r--spec/lib/gitlab/gitaly_client/repository_service_spec.rb13
4 files changed, 91 insertions, 43 deletions
diff --git a/spec/lib/gitlab/gitaly_client/blob_service_spec.rb b/spec/lib/gitlab/gitaly_client/blob_service_spec.rb
index 50078d8c127..f869c66337e 100644
--- a/spec/lib/gitlab/gitaly_client/blob_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/blob_service_spec.rb
@@ -92,13 +92,14 @@ RSpec.describe Gitlab::GitalyClient::BlobService do
describe '#list_blobs' do
let(:limit) { 0 }
let(:bytes_limit) { 0 }
- let(:expected_params) { { revisions: revisions, limit: limit, bytes_limit: bytes_limit } }
+ let(:with_paths) { false }
+ let(:expected_params) { { revisions: revisions, limit: limit, bytes_limit: bytes_limit, with_paths: with_paths } }
before do
::Gitlab::GitalyClient.clear_stubs!
end
- subject { client.list_blobs(revisions, limit: limit, bytes_limit: bytes_limit) }
+ subject { client.list_blobs(revisions, limit: limit, bytes_limit: bytes_limit, with_paths: with_paths) }
context 'with a single revision' do
let(:revisions) { ['master'] }
@@ -147,6 +148,24 @@ RSpec.describe Gitlab::GitalyClient::BlobService do
end
end
+ context 'with paths' do
+ let(:revisions) { ['master'] }
+ let(:limit) { 10 }
+ let(:bytes_lmit) { 1024 }
+ let(:with_paths) { true }
+
+ it 'sends a list_blobs message' do
+ expect_next_instance_of(Gitaly::BlobService::Stub) do |service|
+ expect(service)
+ .to receive(:list_blobs)
+ .with(gitaly_request_with_params(expected_params), kind_of(Hash))
+ .and_return([])
+ end
+
+ subject
+ end
+ end
+
context 'with split contents' do
let(:revisions) { ['master'] }
diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
index a0e2d43cf45..554a91f2bc5 100644
--- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
@@ -311,6 +311,10 @@ RSpec.describe Gitlab::GitalyClient::CommitService do
end
describe '#list_commits' do
+ let(:revisions) { 'master' }
+ let(:reverse) { false }
+ let(:pagination_params) { nil }
+
shared_examples 'a ListCommits request' do
before do
::Gitlab::GitalyClient.clear_stubs!
@@ -318,26 +322,35 @@ RSpec.describe Gitlab::GitalyClient::CommitService do
it 'sends a list_commits message' do
expect_next_instance_of(Gitaly::CommitService::Stub) do |service|
- expect(service)
- .to receive(:list_commits)
- .with(gitaly_request_with_params(expected_params), kind_of(Hash))
- .and_return([])
+ expected_request = gitaly_request_with_params(
+ Array.wrap(revisions),
+ reverse: reverse,
+ pagination_params: pagination_params
+ )
+
+ expect(service).to receive(:list_commits).with(expected_request, kind_of(Hash)).and_return([])
end
- client.list_commits(revisions)
+ client.list_commits(revisions, reverse: reverse, pagination_params: pagination_params)
end
end
- context 'with a single revision' do
- let(:revisions) { 'master' }
- let(:expected_params) { %w[master] }
+ it_behaves_like 'a ListCommits request'
+
+ context 'with multiple revisions' do
+ let(:revisions) { %w[master --not --all] }
+
+ it_behaves_like 'a ListCommits request'
+ end
+
+ context 'with reverse: true' do
+ let(:reverse) { true }
it_behaves_like 'a ListCommits request'
end
- context 'with multiple revisions' do
- let(:revisions) { %w[master --not --all] }
- let(:expected_params) { %w[master --not --all] }
+ context 'with pagination params' do
+ let(:pagination_params) { { limit: 1, page_token: 'foo' } }
it_behaves_like 'a ListCommits request'
end
diff --git a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
index e19be965e68..d308612ef31 100644
--- a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
@@ -92,6 +92,36 @@ RSpec.describe Gitlab::GitalyClient::RefService do
end
end
+ describe '#find_branch' do
+ it 'sends a find_branch message' do
+ expect_any_instance_of(Gitaly::RefService::Stub)
+ .to receive(:find_branch)
+ .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
+ .and_return(double(branch: Gitaly::Branch.new(name: 'name', target_commit: build(:gitaly_commit))))
+
+ client.find_branch('name')
+ end
+ end
+
+ describe '#find_tag' do
+ it 'sends a find_tag message' do
+ expect_any_instance_of(Gitaly::RefService::Stub)
+ .to receive(:find_tag)
+ .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
+ .and_return(double(tag: Gitaly::Tag.new))
+
+ client.find_tag('name')
+ end
+
+ context 'when tag is empty' do
+ it 'does not send a fing_tag message' do
+ expect_any_instance_of(Gitaly::RefService::Stub).not_to receive(:find_tag)
+
+ expect(client.find_tag('')).to be_nil
+ end
+ end
+ end
+
describe '#default_branch_name' do
it 'sends a find_default_branch_name message' do
expect_any_instance_of(Gitaly::RefService::Stub)
@@ -103,16 +133,6 @@ RSpec.describe Gitlab::GitalyClient::RefService do
end
end
- describe '#list_new_blobs' do
- it 'raises DeadlineExceeded when timeout is too small' do
- newrev = '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51'
-
- expect do
- client.list_new_blobs(newrev, dynamic_timeout: 0.001)
- end.to raise_error(GRPC::DeadlineExceeded)
- end
- end
-
describe '#local_branches' do
it 'sends a find_local_branches message' do
expect_any_instance_of(Gitaly::RefService::Stub)
@@ -154,6 +174,22 @@ RSpec.describe Gitlab::GitalyClient::RefService do
client.tags
end
+
+ context 'with sorting option' do
+ it 'sends a correct find_all_tags message' do
+ expected_sort_by = Gitaly::FindAllTagsRequest::SortBy.new(
+ key: :REFNAME,
+ direction: :ASCENDING
+ )
+
+ expect_any_instance_of(Gitaly::RefService::Stub)
+ .to receive(:find_all_tags)
+ .with(gitaly_request_with_params(sort_by: expected_sort_by), kind_of(Hash))
+ .and_return([])
+
+ client.tags(sort_by: 'name_asc')
+ end
+ end
end
describe '#branch_names_contains_sha' do
@@ -189,13 +225,6 @@ RSpec.describe Gitlab::GitalyClient::RefService do
end
end
- describe '#find_ref_name', :seed_helper do
- subject { client.find_ref_name(SeedRepo::Commit::ID, 'refs/heads/master') }
-
- it { is_expected.to be_utf8 }
- it { is_expected.to eq('refs/heads/master') }
- end
-
describe '#ref_exists?', :seed_helper do
it 'finds the master branch ref' do
expect(client.ref_exists?('refs/heads/master')).to eq(true)
diff --git a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb
index 4b037d3f836..e5502a883b5 100644
--- a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb
@@ -195,19 +195,6 @@ RSpec.describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#squash_in_progress?' do
- let(:squash_id) { 1 }
-
- it 'sends a repository_squash_in_progress message' do
- expect_any_instance_of(Gitaly::RepositoryService::Stub)
- .to receive(:is_squash_in_progress)
- .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
- .and_return(double(in_progress: true))
-
- client.squash_in_progress?(squash_id)
- end
- end
-
describe '#calculate_checksum' do
it 'sends a calculate_checksum message' do
expect_any_instance_of(Gitaly::RepositoryService::Stub)