MCPcopy
hub / github.com/perkeep/perkeep / TestIndexingPermanodeMissingPubkey

Function TestIndexingPermanodeMissingPubkey

pkg/index/index_test.go:537–582  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

535}
536
537func TestIndexingPermanodeMissingPubkey(t *testing.T) {
538 s := sorted.NewMemoryKeyValue()
539 idx, err := index.New(s)
540 if err != nil {
541 t.Fatal(err)
542 }
543
544 id := indextest.NewIndexDeps(idx)
545 id.Fataler = t
546
547 goodKeyFetcher := id.Index.KeyFetcher
548 emptyFetcher := new(test.Fetcher)
549
550 // Prevent the index from being able to find the public key:
551 idx.KeyFetcher = emptyFetcher
552
553 pn := id.NewPermanode()
554
555 // Verify that populateClaim noted the missing public key blob:
556 {
557 key := fmt.Sprintf("missing|%s|%s", pn, id.SignerBlobRef)
558 if got, err := s.Get(key); got == "" || err != nil {
559 t.Errorf("key %q missing (err: %v); want 1", key, err)
560 }
561 }
562
563 // Now make it available again:
564 idx.KeyFetcher = idx.Exp_BlobSource()
565
566 if err := copyBlob(id.SignerBlobRef, idx.Exp_BlobSource().(*test.Fetcher), goodKeyFetcher); err != nil {
567 t.Errorf("Error copying public key to BlobSource: %v", err)
568 }
569 if err := copyBlob(id.SignerBlobRef, idx, goodKeyFetcher); err != nil {
570 t.Errorf("Error uploading public key to indexer: %v", err)
571 }
572
573 idx.Exp_AwaitAsyncIndexing(t)
574
575 // Verify that populateClaim noted the now present public key blob:
576 {
577 key := fmt.Sprintf("missing|%s|%s", pn, id.SignerBlobRef)
578 if got, err := s.Get(key); got != "" || err == nil {
579 t.Errorf("row %q still exists", key)
580 }
581 }
582}
583
584func copyBlob(br blob.Ref, dst blobserver.BlobReceiver, src blob.Fetcher) error {
585 rc, _, err := src.Fetch(ctxbg, br)

Callers

nothing calls this directly

Calls 9

NewPermanodeMethod · 0.95
NewMemoryKeyValueFunction · 0.92
NewFunction · 0.92
NewIndexDepsFunction · 0.92
copyBlobFunction · 0.85
FatalMethod · 0.80
Exp_BlobSourceMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected