(ctx context.Context, t *testing.T, cs content.Store)
| 319 | } |
| 320 | |
| 321 | func checkCommitExists(ctx context.Context, t *testing.T, cs content.Store) { |
| 322 | c1, d1 := createContent(256) |
| 323 | if err := content.WriteBlob(ctx, cs, "c1", bytes.NewReader(c1), ocispec.Descriptor{Digest: d1}); err != nil { |
| 324 | t.Fatal(err) |
| 325 | } |
| 326 | |
| 327 | for i, tc := range []struct { |
| 328 | expected digest.Digest |
| 329 | }{ |
| 330 | { |
| 331 | expected: d1, |
| 332 | }, |
| 333 | {}, |
| 334 | } { |
| 335 | w, err := content.OpenWriter(ctx, cs, content.WithRef(fmt.Sprintf("c1-commitexists-%d", i))) |
| 336 | if err != nil { |
| 337 | t.Fatal(err) |
| 338 | } |
| 339 | if _, err := w.Write(c1); err != nil { |
| 340 | w.Close() |
| 341 | t.Fatal(err) |
| 342 | } |
| 343 | err = w.Commit(ctx, int64(len(c1)), tc.expected) |
| 344 | w.Close() |
| 345 | if err == nil { |
| 346 | t.Errorf("(%d) Expected already exists error", i) |
| 347 | } else if !errdefs.IsAlreadyExists(err) { |
| 348 | t.Fatalf("(%d) Unexpected error: %+v", i, err) |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | func checkRefNotAvailable(ctx context.Context, t *testing.T, cs content.Store, ref string) { |
| 354 | t.Helper() |
nothing calls this directly
no test coverage detected
searching dependent graphs…