diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/services/dependency_proxy | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/services/dependency_proxy')
-rw-r--r-- | spec/services/dependency_proxy/find_cached_manifest_service_spec.rb | 30 |
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 |