summaryrefslogtreecommitdiff
path: root/spec/lib/container_registry
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/container_registry')
-rw-r--r--spec/lib/container_registry/client_spec.rb65
-rw-r--r--spec/lib/container_registry/tag_spec.rb4
2 files changed, 2 insertions, 67 deletions
diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb
index 3782c30e88a..6c2b338bfcd 100644
--- a/spec/lib/container_registry/client_spec.rb
+++ b/spec/lib/container_registry/client_spec.rb
@@ -73,69 +73,4 @@ describe ContainerRegistry::Client do
expect(response).to eq('Successfully redirected')
end
end
-
- def stub_upload(path, content, digest, status = 200)
- stub_request(:post, "http://container-registry/v2/#{path}/blobs/uploads/")
- .to_return(status: status, body: "", headers: { 'location' => 'http://container-registry/next_upload?id=someid' })
-
- stub_request(:put, "http://container-registry/next_upload?digest=#{digest}&id=someid")
- .with(body: content)
- .to_return(status: status, body: "", headers: {})
- end
-
- describe '#upload_blob' do
- subject { client.upload_blob('path', 'content', 'sha256:123') }
-
- context 'with successful uploads' do
- it 'starts the upload and posts the blob' do
- stub_upload('path', 'content', 'sha256:123')
-
- expect(subject).to be_success
- end
- end
-
- context 'with a failed upload' do
- before do
- stub_upload('path', 'content', 'sha256:123', 400)
- end
-
- it 'returns nil' do
- expect(subject).to be nil
- end
- end
- end
-
- describe '#generate_empty_manifest' do
- subject { client.generate_empty_manifest('path') }
-
- let(:result_manifest) do
- {
- schemaVersion: 2,
- mediaType: 'application/vnd.docker.distribution.manifest.v2+json',
- config: {
- mediaType: 'application/vnd.docker.container.image.v1+json',
- size: 21,
- digest: 'sha256:4435000728ee66e6a80e55637fc22725c256b61de344a2ecdeaac6bdb36e8bc3'
- }
- }
- end
-
- it 'uploads a random image and returns the manifest' do
- stub_upload('path', "{\n \"config\": {\n }\n}", 'sha256:4435000728ee66e6a80e55637fc22725c256b61de344a2ecdeaac6bdb36e8bc3')
-
- expect(subject).to eq(result_manifest)
- end
- end
-
- describe '#put_tag' do
- subject { client.put_tag('path', 'tagA', { foo: :bar }) }
-
- it 'uploads the manifest and returns the digest' do
- stub_request(:put, "http://container-registry/v2/path/manifests/tagA")
- .with(body: "{\n \"foo\": \"bar\"\n}")
- .to_return(status: 200, body: "", headers: { 'docker-content-digest' => 'sha256:123' })
-
- expect(subject).to eq 'sha256:123'
- end
- end
end
diff --git a/spec/lib/container_registry/tag_spec.rb b/spec/lib/container_registry/tag_spec.rb
index 3115dfe852f..110f006536b 100644
--- a/spec/lib/container_registry/tag_spec.rb
+++ b/spec/lib/container_registry/tag_spec.rb
@@ -179,7 +179,7 @@ describe ContainerRegistry::Tag do
end
end
- describe '#unsafe_delete' do
+ describe '#delete' do
before do
stub_request(:delete, 'http://registry.gitlab/v2/group/test/manifests/sha256:digest')
.with(headers: headers)
@@ -187,7 +187,7 @@ describe ContainerRegistry::Tag do
end
it 'correctly deletes the tag' do
- expect(tag.unsafe_delete).to be_truthy
+ expect(tag.delete).to be_truthy
end
end
end