(t *testing.T)
| 30 | var ctxbg = context.Background() |
| 31 | |
| 32 | func 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 | |
| 61 | func TestReceiveCorrupt(t *testing.T) { |
| 62 | sto := new(test.Fetcher) |
nothing calls this directly
no test coverage detected