File: container_registry_spec.rb

package info (click to toggle)
ruby-gitlab 5.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,660 kB
  • sloc: ruby: 12,582; makefile: 7; sh: 4
file content (98 lines) | stat: -rw-r--r-- 3,376 bytes parent folder | download
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Client do
  describe '.registry_repositories' do
    before do
      stub_get('/projects/3/registry/repositories', 'registry_repositories')
      @registry_repositories = Gitlab.registry_repositories(3)
    end

    it 'gets the correct resource' do
      expect(a_get('/projects/3/registry/repositories')).to have_been_made
    end

    it "returns a paginated response of project's registry repositories" do
      expect(@registry_repositories).to be_a Gitlab::PaginatedResponse
    end
  end

  describe '.delete_registry_repository' do
    before do
      stub_delete('/projects/3/registry/repositories/1', 'empty')
      Gitlab.delete_registry_repository(3, 1)
    end

    it 'gets the correct resource' do
      expect(a_delete('/projects/3/registry/repositories/1')).to have_been_made
    end
  end

  describe '.registry_repository_tags' do
    before do
      stub_get('/projects/3/registry/repositories/1/tags', 'registry_repository_tags')
      @registry_repository_tags = Gitlab.registry_repository_tags(3, 1)
    end

    it 'gets the correct resource' do
      expect(a_get('/projects/3/registry/repositories/1/tags')).to have_been_made
    end

    it "returns a paginated response of a registry repository's tags" do
      expect(@registry_repository_tags).to be_a Gitlab::PaginatedResponse
    end
  end

  describe '.registry_repository_tag' do
    before do
      stub_get('/projects/3/registry/repositories/1/tags/v10.0.0', 'registry_repository_tag')
      @registry_repository_tag = Gitlab.registry_repository_tag(3, 1, 'v10.0.0')
    end

    it 'gets the correct resource' do
      expect(a_get('/projects/3/registry/repositories/1/tags/v10.0.0')).to have_been_made
    end

    it 'returns correct information about the registry repository tag' do
      expect(@registry_repository_tag.name).to eq 'v10.0.0'
    end
  end

  describe '.delete_registry_repository_tag' do
    before do
      stub_delete('/projects/3/registry/repositories/1/tags/v10.0.0', 'empty')
      Gitlab.delete_registry_repository_tag(3, 1, 'v10.0.0')
    end

    it 'gets the correct resource' do
      expect(a_delete('/projects/3/registry/repositories/1/tags/v10.0.0')).to have_been_made
    end
  end

  describe '.bulk_delete_registry_repository_tags' do
    context 'when just name_regex provided for deletion' do
      before do
        stub_delete('/projects/3/registry/repositories/1/tags', 'empty').with(body: { name_regex: '.*' })
        Gitlab.bulk_delete_registry_repository_tags(3, 1, name_regex: '.*')
      end

      it 'gets the correct resource' do
        expect(a_delete('/projects/3/registry/repositories/1/tags')
          .with(body: { name_regex: '.*' })).to have_been_made
      end
    end

    context 'when all options provided for deletion' do
      before do
        stub_delete('/projects/3/registry/repositories/1/tags', 'empty').with(body: { name_regex: '[0-9a-z]{40}', keep_n: 5, older_than: '1d' })
        Gitlab.bulk_delete_registry_repository_tags(3, 1, name_regex: '[0-9a-z]{40}', keep_n: 5, older_than: '1d')
      end

      it 'gets the correct resource' do
        expect(a_delete('/projects/3/registry/repositories/1/tags')
          .with(body: { name_regex: '[0-9a-z]{40}', keep_n: 5, older_than: '1d' })).to have_been_made
      end
    end
  end
end