fix panic in TestSubFailFully

This commit is contained in:
Marten Seemann 2022-08-17 11:56:53 +03:00
parent eef4f37eb1
commit 8f33a3e22f

View File

@ -455,11 +455,6 @@ 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))
@ -472,9 +467,17 @@ func TestSubFailFully(t *testing.T) {
t.Fatal(err)
}
go panicOnTimeout(5 * time.Second)
done := make(chan struct{})
go func() {
defer close(done)
em.Emit(EventB(159)) // will hang if sub doesn't fail properly
}()
select {
case <-done:
case <-time.After(5 * time.Second):
t.Fatal("timeout")
}
}
func testMany(t testing.TB, subs, emits, msgs int, stateful bool) {