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/support/shared_contexts/lib/container_registry/client_stubs_shared_context.rb')
-rw-r--r--spec/support/shared_contexts/lib/container_registry/client_stubs_shared_context.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/support/shared_contexts/lib/container_registry/client_stubs_shared_context.rb b/spec/support/shared_contexts/lib/container_registry/client_stubs_shared_context.rb
new file mode 100644
index 00000000000..d857e683aa2
--- /dev/null
+++ b/spec/support/shared_contexts/lib/container_registry/client_stubs_shared_context.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+RSpec.shared_context 'container registry client stubs' do
+ def stub_container_registry_gitlab_api_support(supported: true)
+ allow_next_instance_of(ContainerRegistry::GitlabApiClient) do |client|
+ allow(client).to receive(:supports_gitlab_api?).and_return(supported)
+ yield client if block_given?
+ end
+ end
+
+ def stub_container_registry_gitlab_api_repository_details(client, path:, size_bytes:)
+ allow(client).to receive(:repository_details).with(path, with_size: true).and_return('size_bytes' => size_bytes)
+ end
+
+ def stub_container_registry_gitlab_api_network_error(client_method: :supports_gitlab_api?)
+ allow_next_instance_of(ContainerRegistry::GitlabApiClient) do |client|
+ allow(client).to receive(client_method).and_raise(::Faraday::Error, nil, nil)
+ end
+ end
+end