1package mocks
2
3import (
4 "io"
5 "github.com/stretchr/testify/mock"
6)
7
8// MockStorage is a mock implementation of registry.Storage
9type MockStorage struct {
10 mock.Mock
11}
12
13// Manifest operations
14func (m *MockStorage) GetManifest(name, reference string) ([]byte, string, error) {
15 args := m.Called(name, reference)
16 if args.Get(0) == nil {
17 return nil, "", args.Error(2)
18 }
19 return args.Get(0).([]byte), args.String(1), args.Error(2)
20}
21
22func (m *MockStorage) PutManifest(name, reference, contentType string, data []byte) error {
23 args := m.Called(name, reference, contentType, data)
24 return args.Error(0)
25}
26
27func (m *MockStorage) DeleteManifest(name, reference string) error {
28 args := m.Called(name, reference)
29 return args.Error(0)
30}
31
32// Blob operations
33func (m *MockStorage) GetBlob(digest string) (io.ReadCloser, error) {
34 args := m.Called(digest)
35 if args.Get(0) == nil {
36 return nil, args.Error(1)
37 }
38 return args.Get(0).(io.ReadCloser), args.Error(1)
39}
40
41func (m *MockStorage) GetBlobPath(digest string) (string, error) {
42 args := m.Called(digest)
43 return args.String(0), args.Error(1)
44}
45
46func (m *MockStorage) PutBlob(digest string, data io.Reader, size int64) error {
47 args := m.Called(digest, data, size)
48 return args.Error(0)
49}
50
51func (m *MockStorage) DeleteBlob(digest string) error {
52 args := m.Called(digest)
53 return args.Error(0)
54}
55
56func (m *MockStorage) BlobExists(digest string) bool {
57 args := m.Called(digest)
58 return args.Bool(0)
59}
60
61// Upload operations
62func (m *MockStorage) StartBlobUpload(name string) (string, error) {
63 args := m.Called(name)
64 return args.String(0), args.Error(1)
65}
66
67func (m *MockStorage) AppendBlobChunk(name, uuid string, chunk []byte) (int64, error) {
68 args := m.Called(name, uuid, chunk)
69 return args.Get(0).(int64), args.Error(1)
70}
71
72func (m *MockStorage) GetBlobUpload(uuid string) (io.WriteCloser, error) {
73 args := m.Called(uuid)
74 if args.Get(0) == nil {
75 return nil, args.Error(1)
76 }
77 return args.Get(0).(io.WriteCloser), args.Error(1)
78}
79
80func (m *MockStorage) FinishBlobUpload(uuid, digest string) error {
81 args := m.Called(uuid, digest)
82 return args.Error(0)
83}
84
85func (m *MockStorage) CancelBlobUpload(uuid string) error {
86 args := m.Called(uuid)
87 return args.Error(0)
88}
89
90// Tag operations
91func (m *MockStorage) ListTags(name string) ([]string, error) {
92 args := m.Called(name)
93 if args.Get(0) == nil {
94 return nil, args.Error(1)
95 }
96 return args.Get(0).([]string), args.Error(1)
97}
98
99// Repository operations
100func (m *MockStorage) ListRepositories() ([]string, error) {
101 args := m.Called()
102 if args.Get(0) == nil {
103 return nil, args.Error(1)
104 }
105 return args.Get(0).([]string), args.Error(1)
106}