MCPcopy
hub / github.com/perkeep/perkeep / TestHubFiring

Function TestHubFiring

pkg/blobserver/blobhub_test.go:100–133  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

98}
99
100func 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}

Callers

nothing calls this directly

Calls 7

NotifyBlobReceivedMethod · 0.95
RegisterListenerMethod · 0.95
RegisterBlobListenerMethod · 0.95
MustParseFunction · 0.92
FatalMethod · 0.80
FatalfMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected