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/services/dependency_proxy/find_cached_manifest_service_spec.rb')
-rw-r--r--spec/services/dependency_proxy/find_cached_manifest_service_spec.rb30
1 files changed, 25 insertions, 5 deletions
diff --git a/spec/services/dependency_proxy/find_cached_manifest_service_spec.rb b/spec/services/dependency_proxy/find_cached_manifest_service_spec.rb
index 607d67d8efe..470c6eb9e03 100644
--- a/spec/services/dependency_proxy/find_cached_manifest_service_spec.rb
+++ b/spec/services/dependency_proxy/find_cached_manifest_service_spec.rb
@@ -39,6 +39,14 @@ RSpec.describe DependencyProxy::FindCachedManifestService do
end
end
+ shared_examples 'returning an error' do
+ it 'returns an error', :aggregate_failures do
+ expect(subject[:status]).to eq(:error)
+ expect(subject[:http_status]).to eq(503)
+ expect(subject[:message]).to eq('Failed to download the manifest from the external registry')
+ end
+ end
+
context 'when no manifest exists' do
let_it_be(:image) { 'new-image' }
@@ -101,7 +109,7 @@ RSpec.describe DependencyProxy::FindCachedManifestService do
it_behaves_like 'returning no manifest'
end
- context 'failed connection' do
+ context 'when the connection fails' do
before do
expect(DependencyProxy::HeadManifestService).to receive(:new).and_raise(Net::OpenTimeout)
end
@@ -111,12 +119,24 @@ RSpec.describe DependencyProxy::FindCachedManifestService do
context 'and no manifest is cached' do
let_it_be(:image) { 'new-image' }
- it 'returns an error', :aggregate_failures do
- expect(subject[:status]).to eq(:error)
- expect(subject[:http_status]).to eq(503)
- expect(subject[:message]).to eq('Failed to download the manifest from the external registry')
+ it_behaves_like 'returning an error'
+ end
+ end
+
+ context 'when the connection is successful but with error in result' do
+ before do
+ allow_next_instance_of(DependencyProxy::HeadManifestService) do |service|
+ allow(service).to receive(:execute).and_return(status: :error, http_status: 401, message: "Not found")
end
end
+
+ it_behaves_like 'using the cached manifest'
+
+ context 'and no manifest is cached' do
+ let_it_be(:image) { 'new-image' }
+
+ it_behaves_like 'returning no manifest'
+ end
end
end
end