MCPcopy
hub / github.com/containerd/containerd / checkCommitExists

Function checkCommitExists

core/content/testsuite/testsuite.go:321–351  ·  view source on GitHub ↗
(ctx context.Context, t *testing.T, cs content.Store)

Source from the content-addressed store, hash-verified

319}
320
321func 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
353func checkRefNotAvailable(ctx context.Context, t *testing.T, cs content.Store, ref string) {
354 t.Helper()

Callers

nothing calls this directly

Calls 8

WriteBlobFunction · 0.92
OpenWriterFunction · 0.92
WithRefFunction · 0.92
FatalMethod · 0.80
createContentFunction · 0.70
WriteMethod · 0.65
CloseMethod · 0.65
CommitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…