Make the test fail in reasonable time

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera 2019-06-22 15:45:09 +02:00
parent 3fd76c7eac
commit 454cbe5497

View File

@ -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
}