github.com/devseccon/trivy@v0.47.1-0.20231123133102-bd902a0bd996/pkg/fanal/cache/mock_artifact_cache.go (about) 1 // Code generated by mockery v1.0.0. DO NOT EDIT. 2 3 package cache 4 5 import ( 6 mock "github.com/stretchr/testify/mock" 7 8 types "github.com/devseccon/trivy/pkg/fanal/types" 9 ) 10 11 // MockArtifactCache is an autogenerated mock type for the ArtifactCache type 12 type MockArtifactCache struct { 13 mock.Mock 14 } 15 16 type ArtifactCacheDeleteBlobsArgs struct { 17 BlobIDs []string 18 BlobIDsAnything bool 19 } 20 21 type ArtifactCacheDeleteBlobsReturns struct { 22 _a0 error 23 } 24 25 type ArtifactCacheDeleteBlobsExpectation struct { 26 Args ArtifactCacheDeleteBlobsArgs 27 Returns ArtifactCacheDeleteBlobsReturns 28 } 29 30 func (_m *MockArtifactCache) ApplyDeleteBlobsExpectation(e ArtifactCacheDeleteBlobsExpectation) { 31 var args []interface{} 32 if e.Args.BlobIDsAnything { 33 args = append(args, mock.Anything) 34 } else { 35 args = append(args, e.Args.BlobIDs) 36 } 37 _m.On("DeleteBlobs", args...).Return(e.Returns._a0) 38 } 39 40 func (_m *MockArtifactCache) ApplyDeleteBlobsExpectations(expectations []ArtifactCacheDeleteBlobsExpectation) { 41 for _, e := range expectations { 42 _m.ApplyDeleteBlobsExpectation(e) 43 } 44 } 45 46 // DeleteBlobs provides a mock function with given fields: blobIDs 47 func (_m *MockArtifactCache) DeleteBlobs(blobIDs []string) error { 48 ret := _m.Called(blobIDs) 49 50 var r0 error 51 if rf, ok := ret.Get(0).(func([]string) error); ok { 52 r0 = rf(blobIDs) 53 } else { 54 r0 = ret.Error(0) 55 } 56 57 return r0 58 } 59 60 type ArtifactCacheMissingBlobsArgs struct { 61 ArtifactID string 62 ArtifactIDAnything bool 63 BlobIDs []string 64 BlobIDsAnything bool 65 } 66 67 type ArtifactCacheMissingBlobsReturns struct { 68 MissingArtifact bool 69 MissingBlobIDs []string 70 Err error 71 } 72 73 type ArtifactCacheMissingBlobsExpectation struct { 74 Args ArtifactCacheMissingBlobsArgs 75 Returns ArtifactCacheMissingBlobsReturns 76 } 77 78 func (_m *MockArtifactCache) ApplyMissingBlobsExpectation(e ArtifactCacheMissingBlobsExpectation) { 79 var args []interface{} 80 if e.Args.ArtifactIDAnything { 81 args = append(args, mock.Anything) 82 } else { 83 args = append(args, e.Args.ArtifactID) 84 } 85 if e.Args.BlobIDsAnything { 86 args = append(args, mock.Anything) 87 } else { 88 args = append(args, e.Args.BlobIDs) 89 } 90 _m.On("MissingBlobs", args...).Return(e.Returns.MissingArtifact, e.Returns.MissingBlobIDs, e.Returns.Err) 91 } 92 93 func (_m *MockArtifactCache) ApplyMissingBlobsExpectations(expectations []ArtifactCacheMissingBlobsExpectation) { 94 for _, e := range expectations { 95 _m.ApplyMissingBlobsExpectation(e) 96 } 97 } 98 99 // MissingBlobs provides a mock function with given fields: artifactID, blobIDs 100 func (_m *MockArtifactCache) MissingBlobs(artifactID string, blobIDs []string) (bool, []string, error) { 101 ret := _m.Called(artifactID, blobIDs) 102 103 var r0 bool 104 if rf, ok := ret.Get(0).(func(string, []string) bool); ok { 105 r0 = rf(artifactID, blobIDs) 106 } else { 107 r0 = ret.Get(0).(bool) 108 } 109 110 var r1 []string 111 if rf, ok := ret.Get(1).(func(string, []string) []string); ok { 112 r1 = rf(artifactID, blobIDs) 113 } else { 114 if ret.Get(1) != nil { 115 r1 = ret.Get(1).([]string) 116 } 117 } 118 119 var r2 error 120 if rf, ok := ret.Get(2).(func(string, []string) error); ok { 121 r2 = rf(artifactID, blobIDs) 122 } else { 123 r2 = ret.Error(2) 124 } 125 126 return r0, r1, r2 127 } 128 129 type ArtifactCachePutArtifactArgs struct { 130 ArtifactID string 131 ArtifactIDAnything bool 132 ArtifactInfo types.ArtifactInfo 133 ArtifactInfoAnything bool 134 } 135 136 type ArtifactCachePutArtifactReturns struct { 137 Err error 138 } 139 140 type ArtifactCachePutArtifactExpectation struct { 141 Args ArtifactCachePutArtifactArgs 142 Returns ArtifactCachePutArtifactReturns 143 } 144 145 func (_m *MockArtifactCache) ApplyPutArtifactExpectation(e ArtifactCachePutArtifactExpectation) { 146 var args []interface{} 147 if e.Args.ArtifactIDAnything { 148 args = append(args, mock.Anything) 149 } else { 150 args = append(args, e.Args.ArtifactID) 151 } 152 if e.Args.ArtifactInfoAnything { 153 args = append(args, mock.Anything) 154 } else { 155 args = append(args, e.Args.ArtifactInfo) 156 } 157 _m.On("PutArtifact", args...).Return(e.Returns.Err) 158 } 159 160 func (_m *MockArtifactCache) ApplyPutArtifactExpectations(expectations []ArtifactCachePutArtifactExpectation) { 161 for _, e := range expectations { 162 _m.ApplyPutArtifactExpectation(e) 163 } 164 } 165 166 // PutArtifact provides a mock function with given fields: artifactID, artifactInfo 167 func (_m *MockArtifactCache) PutArtifact(artifactID string, artifactInfo types.ArtifactInfo) error { 168 ret := _m.Called(artifactID, artifactInfo) 169 170 var r0 error 171 if rf, ok := ret.Get(0).(func(string, types.ArtifactInfo) error); ok { 172 r0 = rf(artifactID, artifactInfo) 173 } else { 174 r0 = ret.Error(0) 175 } 176 177 return r0 178 } 179 180 type ArtifactCachePutBlobArgs struct { 181 BlobID string 182 BlobIDAnything bool 183 BlobInfo types.BlobInfo 184 BlobInfoAnything bool 185 } 186 187 type ArtifactCachePutBlobReturns struct { 188 Err error 189 } 190 191 type ArtifactCachePutBlobExpectation struct { 192 Args ArtifactCachePutBlobArgs 193 Returns ArtifactCachePutBlobReturns 194 } 195 196 func (_m *MockArtifactCache) ApplyPutBlobExpectation(e ArtifactCachePutBlobExpectation) { 197 var args []interface{} 198 if e.Args.BlobIDAnything { 199 args = append(args, mock.Anything) 200 } else { 201 args = append(args, e.Args.BlobID) 202 } 203 if e.Args.BlobInfoAnything { 204 args = append(args, mock.Anything) 205 } else { 206 args = append(args, e.Args.BlobInfo) 207 } 208 _m.On("PutBlob", args...).Return(e.Returns.Err) 209 } 210 211 func (_m *MockArtifactCache) ApplyPutBlobExpectations(expectations []ArtifactCachePutBlobExpectation) { 212 for _, e := range expectations { 213 _m.ApplyPutBlobExpectation(e) 214 } 215 } 216 217 // PutBlob provides a mock function with given fields: blobID, blobInfo 218 func (_m *MockArtifactCache) PutBlob(blobID string, blobInfo types.BlobInfo) error { 219 220 for i := range blobInfo.Misconfigurations { 221 // suppress misconfiguration code block 222 for j := range blobInfo.Misconfigurations[i].Failures { 223 blobInfo.Misconfigurations[i].Failures[j].Code = types.Code{} 224 } 225 for j := range blobInfo.Misconfigurations[i].Successes { 226 blobInfo.Misconfigurations[i].Successes[j].Code = types.Code{} 227 } 228 for j := range blobInfo.Misconfigurations[i].Warnings { 229 blobInfo.Misconfigurations[i].Warnings[j].Code = types.Code{} 230 } 231 for j := range blobInfo.Misconfigurations[i].Exceptions { 232 blobInfo.Misconfigurations[i].Exceptions[j].Code = types.Code{} 233 } 234 } 235 236 ret := _m.Called(blobID, blobInfo) 237 238 var r0 error 239 if rf, ok := ret.Get(0).(func(string, types.BlobInfo) error); ok { 240 r0 = rf(blobID, blobInfo) 241 } else { 242 r0 = ret.Error(0) 243 } 244 245 return r0 246 }