From 16976a34d4c919f478966a3068f0f95f02da3897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 22 Jun 2019 15:14:04 +0200 Subject: [PATCH] Add test for #10 --- p2p/host/eventbus/basic_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/p2p/host/eventbus/basic_test.go b/p2p/host/eventbus/basic_test.go index 62b84eb1cf..aaad88afb6 100644 --- a/p2p/host/eventbus/basic_test.go +++ b/p2p/host/eventbus/basic_test.go @@ -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()