Commit 10b0fb1b authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove redundant stubs from container image tag specs

parent 662d2e68
...@@ -5,10 +5,9 @@ describe ContainerRegistry::Tag do ...@@ -5,10 +5,9 @@ describe ContainerRegistry::Tag do
let(:project) { create(:project, path: 'test', group: group) } let(:project) { create(:project, path: 'test', group: group) }
let(:repository) do let(:repository) do
create(:container_repository, name: '', tags: %w[latest], project: project) create(:container_repository, name: '', project: project)
end end
# TODO, move stubs to helper with this header
let(:headers) do let(:headers) do
{ 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' } { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' }
end end
...@@ -41,7 +40,7 @@ describe ContainerRegistry::Tag do ...@@ -41,7 +40,7 @@ describe ContainerRegistry::Tag do
context 'when tag belongs to first-level repository' do context 'when tag belongs to first-level repository' do
let(:repository) do let(:repository) do
create(:container_repository, name: 'my_image', create(:container_repository, name: 'my_image',
tags: %w[latest], tags: %w[tag],
project: project) project: project)
end end
...@@ -158,29 +157,29 @@ describe ContainerRegistry::Tag do ...@@ -158,29 +157,29 @@ describe ContainerRegistry::Tag do
end end
end end
context 'manifest digest' do context 'with stubbed digest' do
before do before do
stub_request(:head, 'http://registry.gitlab/v2/group/test/manifests/tag'). stub_request(:head, 'http://registry.gitlab/v2/group/test/manifests/tag')
with(headers: headers). .with(headers: headers)
to_return(status: 200, headers: { 'Docker-Content-Digest' => 'sha256:digest' }) .to_return(status: 200, headers: { 'Docker-Content-Digest' => 'sha256:digest' })
end end
context '#digest' do describe '#digest' do
subject { tag.digest } it 'returns a correct tag digest' do
expect(tag.digest).to eq 'sha256:digest'
it { is_expected.to eq('sha256:digest') } end
end end
context '#delete' do describe '#delete' do
before do before do
stub_request(:delete, 'http://registry.gitlab/v2/group/test/manifests/sha256:digest'). stub_request(:delete, 'http://registry.gitlab/v2/group/test/manifests/sha256:digest')
with(headers: headers). .with(headers: headers)
to_return(status: 200) .to_return(status: 200)
end end
subject { tag.delete } it 'correctly deletes the tag' do
expect(tag.delete).to be_truthy
it { is_expected.to be_truthy } end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment