MCPcopy
hub / github.com/perkeep/perkeep / TestIssue305

Function TestIssue305

pkg/schema/schema_test.go:490–525  ·  view source on GitHub ↗

perkeep.org/issue/305

(t *testing.T)

Source from the content-addressed store, hash-verified

488
489// perkeep.org/issue/305
490func TestIssue305(t *testing.T) {
491 var in = `{"camliVersion": 1,
492 "camliType": "file",
493 "fileName": "2012-03-10 15.03.18.m4v",
494 "parts": [
495 {
496 "bytesRef": "sha1-c76d8b17b887c207875e61a77b7eccc60289e61c",
497 "size": 20032564
498 }
499 ]
500}`
501 var ss superset
502 if err := json.NewDecoder(strings.NewReader(in)).Decode(&ss); err != nil {
503 t.Fatal(err)
504 }
505 inref := blob.RefFromString(in)
506 blob, err := BlobFromReader(inref, strings.NewReader(in))
507 if err != nil {
508 t.Fatal(err)
509 }
510 if blob.BlobRef() != inref {
511 t.Errorf("original ref = %s; want %s", blob.BlobRef(), inref)
512 }
513 bb := blob.Builder()
514 jback, err := bb.JSON()
515 if err != nil {
516 t.Fatal(err)
517 }
518 if jback != in {
519 t.Errorf("JSON doesn't match:\n got: %q\nwant: %q\n", jback, in)
520 }
521 out := bb.Blob()
522 if got := out.BlobRef(); got != inref {
523 t.Errorf("cloned ref = %v; want %v", got, inref)
524 }
525}
526
527func TestStaticFileAndStaticSymlink(t *testing.T) {
528 // TODO (marete): Split this into two test functions.

Callers

nothing calls this directly

Calls 7

RefFromStringFunction · 0.92
BlobFromReaderFunction · 0.85
FatalMethod · 0.80
BlobRefMethod · 0.65
BuilderMethod · 0.65
BlobMethod · 0.65
JSONMethod · 0.45

Tested by

no test coverage detected