MCPcopy
hub / github.com/containerd/containerd / TestReadBlob_WithDescriptorData

Function TestReadBlob_WithDescriptorData

core/content/helpers_test.go:485–567  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

483}
484
485func TestReadBlob_WithDescriptorData(t *testing.T) {
486 helloData := []byte("hello")
487 helloDigest := digest.FromBytes(helloData)
488 providerData := []byte("from provider")
489
490 tests := []struct {
491 name string
492 desc ocispec.Descriptor
493 providerContent []byte
494 wantContent string
495 wantError bool
496 wantProviderUsed bool
497 }{
498 {
499 name: "valid embedded data bypasses provider",
500 desc: ocispec.Descriptor{
501 Data: helloData,
502 Size: int64(len(helloData)),
503 Digest: helloDigest,
504 },
505 providerContent: providerData,
506 wantContent: "hello",
507 wantProviderUsed: false,
508 },
509 {
510 name: "nil data falls through to provider",
511 desc: ocispec.Descriptor{
512 Data: nil,
513 Size: int64(len(providerData)),
514 Digest: digest.FromBytes(providerData),
515 },
516 providerContent: providerData,
517 wantContent: "from provider",
518 wantProviderUsed: true,
519 },
520 {
521 name: "malformed digest returns error",
522 desc: ocispec.Descriptor{
523 Data: helloData,
524 Size: int64(len(helloData)),
525 Digest: digest.Digest("bad"),
526 },
527 providerContent: providerData,
528 wantError: true,
529 },
530 {
531 name: "digest mismatch falls through to provider",
532 desc: ocispec.Descriptor{
533 Data: helloData,
534 Size: int64(len(helloData)),
535 Digest: digest.FromBytes([]byte("other")),
536 },
537 providerContent: providerData,
538 wantContent: "from provider",
539 wantProviderUsed: true,
540 },
541 {
542 name: "size mismatch falls through to provider",

Callers

nothing calls this directly

Calls 4

ReadBlobFunction · 0.85
DigestMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…