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:
Diffstat (limited to 'spec/lib/container_registry')
-rw-r--r--spec/lib/container_registry/client_spec.rb32
-rw-r--r--spec/lib/container_registry/gitlab_api_client_spec.rb11
2 files changed, 42 insertions, 1 deletions
diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb
index f9e08df3399..cb2da24b712 100644
--- a/spec/lib/container_registry/client_spec.rb
+++ b/spec/lib/container_registry/client_spec.rb
@@ -423,6 +423,22 @@ RSpec.describe ContainerRegistry::Client do
end
end
+ describe '#repository_tags' do
+ let(:path) { 'repository/path' }
+
+ subject { client.repository_tags(path) }
+
+ before do
+ stub_container_registry_config(enabled: true, api_url: registry_api_url, key: 'spec/fixtures/x509_certificate_pk.key')
+ end
+
+ it 'returns a successful response' do
+ stub_registry_tags_list(query_params: { n: described_class::DEFAULT_TAGS_PAGE_SIZE }, tags: %w[t1 t2])
+
+ expect(subject).to eq('tags' => %w[t1 t2])
+ end
+ end
+
describe '.registry_info' do
subject { described_class.registry_info }
@@ -458,6 +474,22 @@ RSpec.describe ContainerRegistry::Client do
)
end
+ def stub_registry_tags_list(query_params: {}, status: 200, tags: ['test_tag'])
+ url = "#{registry_api_url}/v2/#{path}/tags/list"
+
+ unless query_params.empty?
+ url += "?"
+ url += query_params.map { |k, v| "#{k}=#{v}" }.join(',')
+ end
+
+ stub_request(:get, url)
+ .with(headers: { 'Accept' => ContainerRegistry::Client::ACCEPTED_TYPES.join(', ') })
+ .to_return(
+ status: status,
+ body: Gitlab::Json.dump(tags: tags),
+ headers: { 'Content-Type' => 'application/json' })
+ end
+
def expect_new_faraday(times: 1, timeout: true)
request_options = timeout ? expected_faraday_request_options : nil
expect(Faraday)
diff --git a/spec/lib/container_registry/gitlab_api_client_spec.rb b/spec/lib/container_registry/gitlab_api_client_spec.rb
index f19bedbda0e..7d78aad8b13 100644
--- a/spec/lib/container_registry/gitlab_api_client_spec.rb
+++ b/spec/lib/container_registry/gitlab_api_client_spec.rb
@@ -307,7 +307,16 @@ RSpec.describe ContainerRegistry::GitlabApiClient do
stub_tags(path, page_size: page_size, status_code: 404)
end
- it { is_expected.to eq({}) }
+ it 'logs an error and returns an empty hash' do
+ expect(Gitlab::ErrorTracking)
+ .to receive(:log_exception).with(
+ instance_of(described_class::UnsuccessfulResponseError),
+ class: described_class.name,
+ url: "/gitlab/v1/repositories/#{path}/tags/list/",
+ status_code: 404
+ )
+ expect(subject).to eq({})
+ end
end
end