Make the test fail in reasonable time
License: MIT
@@ -318,6 +318,11 @@ func TestCloseBlocking(t *testing.T) {
sub.Close() // cancel sub
}
+func panicOnTimeout(d time.Duration) {
+ <-time.After(d)
+ panic("timeout reached")
+}
+
func TestSubFailFully(t *testing.T) {
bus := NewBus()
em, err := bus.Emitter(new(EventB))
@@ -330,6 +335,8 @@ func TestSubFailFully(t *testing.T) {
t.Fatal(err)
}
+ go panicOnTimeout(5 * time.Second)
+
em.Emit(EventB(159)) // will hang if sub doesn't fail properly
}
