(t *testing.T)
| 98 | } |
| 99 | |
| 100 | func TestHubFiring(t *testing.T) { |
| 101 | hub := &memHub{} |
| 102 | ch := make(chan blob.Ref) |
| 103 | bch := make(chan blob.Ref) |
| 104 | blob1 := blob.MustParse("sha1-0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33") |
| 105 | blobsame := blob.MustParse("sha1-0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33") |
| 106 | |
| 107 | hub.NotifyBlobReceived(blob.SizedRef{Ref: blob1, Size: 123}) // no-op |
| 108 | |
| 109 | hub.RegisterListener(ch) |
| 110 | hub.RegisterBlobListener(blob1, bch) |
| 111 | |
| 112 | hub.NotifyBlobReceived(blob.SizedRef{Ref: blobsame, Size: 456}) |
| 113 | |
| 114 | tmr1 := time.NewTimer(1 * time.Second) |
| 115 | select { |
| 116 | case <-tmr1.C: |
| 117 | t.Fatal("timer expired on receiving from ch") |
| 118 | case got := <-ch: |
| 119 | if got != blob1 { |
| 120 | t.Fatalf("got wrong blob") |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | select { |
| 125 | case <-tmr1.C: |
| 126 | t.Fatal("timer expired on receiving from bch") |
| 127 | case got := <-bch: |
| 128 | if got != blob1 { |
| 129 | t.Fatalf("got wrong blob") |
| 130 | } |
| 131 | } |
| 132 | tmr1.Stop() |
| 133 | } |
nothing calls this directly
no test coverage detected