MCPcopy
hub / github.com/perkeep/perkeep / TestReceive

Function TestReceive

pkg/blobserver/receive_test.go:32–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30var ctxbg = context.Background()
31
32func TestReceive(t *testing.T) {
33 sto := new(test.Fetcher)
34 data := []byte("some blob")
35 br := blob.RefFromBytes(data)
36
37 hub := blobserver.GetHub(sto)
38 ch := make(chan blob.Ref, 1)
39 hub.RegisterListener(ch)
40
41 sb, err := blobserver.Receive(ctxbg, sto, br, bytes.NewReader(data))
42 if err != nil {
43 t.Fatal(err)
44 }
45 if sb.Size != uint32(len(data)) {
46 t.Errorf("received blob size = %d; want %d", sb.Size, len(data))
47 }
48 if sb.Ref != br {
49 t.Errorf("received blob = %v; want %v", sb.Ref, br)
50 }
51 select {
52 case got := <-ch:
53 if got != br {
54 t.Errorf("blobhub notified about %v; want %v", got, br)
55 }
56 case <-time.After(5 * time.Second):
57 t.Error("timeout waiting on blobhub")
58 }
59}
60
61func TestReceiveCorrupt(t *testing.T) {
62 sto := new(test.Fetcher)

Callers

nothing calls this directly

Calls 6

RefFromBytesFunction · 0.92
GetHubFunction · 0.92
ReceiveFunction · 0.92
FatalMethod · 0.80
RegisterListenerMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected