Skip to content

Commit

Permalink
Add test for #10
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jun 22, 2019
1 parent de37ea9 commit 16976a3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions p2p/host/eventbus/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,21 @@ func TestCloseBlocking(t *testing.T) {
sub.Close() // cancel sub
}

func TestSubFailFully(t *testing.T) {
bus := NewBus()
em, err := bus.Emitter(new(EventB))
if err != nil {
t.Fatal(err)
}

_, err = bus.Subscribe([]interface{}{new(EventB), 5})
if err == nil || err.Error() != "subscribe called with non-pointer type" {
t.Fatal(err)
}

em.Emit(EventB(159)) // will hang if sub doesn't fail properly
}

func testMany(t testing.TB, subs, emits, msgs int, stateful bool) {
if race.WithRace() && subs+emits > 5000 {
t.SkipNow()
Expand Down

0 comments on commit 16976a3

Please sign in to comment.