2016-05-17 14:20:11 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ContainerRegistry::Repository do
|
|
|
|
let(:registry) { ContainerRegistry::Registry.new('http://example.com') }
|
|
|
|
let(:repository) { registry.repository('group/test') }
|
|
|
|
|
|
|
|
it { expect(repository).to respond_to(:registry) }
|
|
|
|
it { expect(repository).to delegate_method(:client).to(:registry) }
|
2016-05-23 19:37:59 -04:00
|
|
|
it { expect(repository.tag('test')).not_to be_nil }
|
2016-05-17 14:20:11 -04:00
|
|
|
|
|
|
|
context '#path' do
|
|
|
|
subject { repository.path }
|
|
|
|
|
|
|
|
it { is_expected.to eq('example.com/group/test') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'manifest processing' do
|
|
|
|
before do
|
|
|
|
stub_request(:get, 'http://example.com/v2/group/test/tags/list').
|
|
|
|
with(headers: { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' }).
|
|
|
|
to_return(
|
|
|
|
status: 200,
|
|
|
|
body: JSON.dump(tags: ['test']),
|
2016-06-17 07:24:50 -04:00
|
|
|
headers: { 'Content-Type' => 'application/json' })
|
2016-05-17 14:20:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context '#manifest' do
|
|
|
|
subject { repository.manifest }
|
|
|
|
|
2016-05-23 19:37:59 -04:00
|
|
|
it { is_expected.not_to be_nil }
|
2016-05-17 14:20:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context '#valid?' do
|
|
|
|
subject { repository.valid? }
|
|
|
|
|
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
|
|
|
context '#tags' do
|
|
|
|
subject { repository.tags }
|
|
|
|
|
2016-05-23 19:37:59 -04:00
|
|
|
it { is_expected.not_to be_empty }
|
2016-05-17 14:20:11 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context '#delete_tags' do
|
|
|
|
let(:tag) { ContainerRegistry::Tag.new(repository, 'tag') }
|
|
|
|
|
|
|
|
before { expect(repository).to receive(:tags).twice.and_return([tag]) }
|
|
|
|
|
|
|
|
subject { repository.delete_tags }
|
|
|
|
|
|
|
|
context 'succeeds' do
|
|
|
|
before { expect(tag).to receive(:delete).and_return(true) }
|
|
|
|
|
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'any fails' do
|
|
|
|
before { expect(tag).to receive(:delete).and_return(false) }
|
|
|
|
|
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|