MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / TestDownload

Method TestDownload

pkg/blobmanager/oci/backend_test.go:210–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

208}
209
210func (s *testSuite) TestDownload() {
211 testCases := []struct {
212 name string
213 digest string
214 writer *bytes.Buffer
215 wantErr bool
216 errMsg string
217 want string
218 }{
219 {
220 name: "empty digest",
221 digest: "",
222 wantErr: true,
223 errMsg: "digest is empty",
224 },
225 {
226 name: "get content",
227 digest: s.casResource.Digest,
228 writer: bytes.NewBuffer(nil),
229 want: "hello world",
230 },
231 }
232
233 assert := assert.New(s.T())
234 // Upload a demo image
235 err := s.validBackend.Upload(context.TODO(), bytes.NewBuffer(s.uploadedContent), s.casResource)
236 require.NoError(s.T(), err)
237
238 for _, tc := range testCases {
239 s.T().Run(tc.name, func(t *testing.T) {
240 err := s.validBackend.Download(context.Background(), tc.writer, tc.digest)
241 if tc.wantErr {
242 assert.ErrorContains(err, tc.errMsg)
243 } else {
244 assert.NoError(err)
245 assert.Equal(tc.want, tc.writer.String())
246 }
247 })
248 }
249}
250
251func (s *testSuite) TestCraftImage() {
252 testCases := []struct {

Callers

nothing calls this directly

Calls 4

UploadMethod · 0.65
DownloadMethod · 0.65
StringMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected