| 224 | } |
| 225 | |
| 226 | func (s *testSuite) TestDownload() { |
| 227 | s.T().Run("exist but not uploaded by Chainloop", func(t *testing.T) { |
| 228 | buf := bytes.NewBuffer(nil) |
| 229 | err := s.backend.Download(context.Background(), buf, s.externalObjectDigest) |
| 230 | s.ErrorContains(err, "asset not uploaded by Chainloop") |
| 231 | s.Empty(buf) |
| 232 | }) |
| 233 | |
| 234 | s.T().Run("doesn't exist", func(t *testing.T) { |
| 235 | buf := bytes.NewBuffer(nil) |
| 236 | err := s.backend.Download(context.Background(), buf, "deadbeef") |
| 237 | s.ErrorContains(err, "artifact not found") |
| 238 | s.Empty(buf) |
| 239 | }) |
| 240 | |
| 241 | s.T().Run("exists", func(t *testing.T) { |
| 242 | buf := bytes.NewBuffer(nil) |
| 243 | err := s.backend.Download(context.Background(), buf, s.ownedObjectDigest) |
| 244 | s.NoError(err) |
| 245 | s.Equal("test", buf.String()) |
| 246 | }) |
| 247 | |
| 248 | // s.T().Run("it's been tampered", func(t *testing.T) { |
| 249 | // buf := bytes.NewBuffer(nil) |
| 250 | // err := s.backend.Download(context.Background(), buf, s.tamperedObjectDigest) |
| 251 | // s.ErrorContains(err, "failed to validate integrity of object") |
| 252 | // }) |
| 253 | } |
| 254 | |
| 255 | type testSuite struct { |
| 256 | suite.Suite |