summaryrefslogtreecommitdiff
path: root/spec/lib/container_registry/blob_spec.rb
blob: 4d8cb787ddeef5924d15064bfbe89933f0440793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require 'spec_helper'

describe ContainerRegistry::Blob do
  let(:digest) { 'sha256:0123456789012345' }
  let(:config) do
    {
      'digest' => digest,
      'mediaType' => 'binary',
      'size' => 1000
    }
  end
  
  let(:registry) { ContainerRegistry::Registry.new('http://example.com') }
  let(:repository) { registry.repository('group/test') }
  let(:blob) { repository.blob(config) }

  it { expect(blob).to respond_to(:repository) }
  it { expect(blob).to delegate_method(:registry).to(:repository) }
  it { expect(blob).to delegate_method(:client).to(:repository) }

  context '#path' do
    subject { blob.path }

    it { is_expected.to eq('example.com/group/test@sha256:0123456789012345') }
  end

  context '#digest' do
    subject { blob.digest }

    it { is_expected.to eq(digest) }
  end

  context '#type' do
    subject { blob.type }

    it { is_expected.to eq('binary') }
  end

  context '#revision' do
    subject { blob.revision }

    it { is_expected.to eq('0123456789012345') }
  end

  context '#short_revision' do
    subject { blob.short_revision }

    it { is_expected.to eq('012345678') }
  end

  context '#delete' do
    before do
      stub_request(:delete, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345').
        to_return(status: 200)
    end

    subject { blob.delete }

    it { is_expected.to be_truthy }
  end
end