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/helpers/stub_gitlab_calls.rb')
-rw-r--r--spec/support/helpers/stub_gitlab_calls.rb28
1 files changed, 19 insertions, 9 deletions
diff --git a/spec/support/helpers/stub_gitlab_calls.rb b/spec/support/helpers/stub_gitlab_calls.rb
index 2933f2c78dc..370d20df444 100644
--- a/spec/support/helpers/stub_gitlab_calls.rb
+++ b/spec/support/helpers/stub_gitlab_calls.rb
@@ -36,31 +36,41 @@ module StubGitlabCalls
.to receive(:full_access_token).and_return('token')
end
- def stub_container_registry_tags(repository: :any, tags:)
+ def stub_container_registry_tags(repository: :any, tags: [], with_manifest: false)
repository = any_args if repository == :any
allow_any_instance_of(ContainerRegistry::Client)
.to receive(:repository_tags).with(repository)
.and_return({ 'tags' => tags })
- allow_any_instance_of(ContainerRegistry::Client)
- .to receive(:repository_manifest).with(repository, anything)
- .and_return(stub_container_registry_tag_manifest)
+ if with_manifest
+ tags.each do |tag|
+ allow_any_instance_of(ContainerRegistry::Client)
+ .to receive(:repository_tag_digest)
+ .with(repository, tag)
+ .and_return('sha256:4c8e63ca4cb663ce6c688cb06f1c3' \
+ '72b088dac5b6d7ad7d49cd620d85cf72a15')
+ end
- allow_any_instance_of(ContainerRegistry::Client)
- .to receive(:blob).with(repository, anything, 'application/octet-stream')
- .and_return(stub_container_registry_blob)
+ allow_any_instance_of(ContainerRegistry::Client)
+ .to receive(:repository_manifest).with(repository, anything)
+ .and_return(stub_container_registry_tag_manifest_content)
+
+ allow_any_instance_of(ContainerRegistry::Client)
+ .to receive(:blob).with(repository, anything, 'application/octet-stream')
+ .and_return(stub_container_registry_blob_content)
+ end
end
private
- def stub_container_registry_tag_manifest
+ def stub_container_registry_tag_manifest_content
fixture_path = 'spec/fixtures/container_registry/tag_manifest.json'
JSON.parse(File.read(Rails.root + fixture_path))
end
- def stub_container_registry_blob
+ def stub_container_registry_blob_content
fixture_path = 'spec/fixtures/container_registry/config_blob.json'
File.read(Rails.root + fixture_path)