mirror of
https://github.com/libp2p/go-eventbus.git
synced 2025-03-13 10:20:10 +08:00
Make the test fail in reasonable time
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
parent
3fd76c7eac
commit
454cbe5497
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user