[events] Fix deadlock in TestExchangeBasic

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
This commit is contained in:
Gaurav Singh 2020-06-29 23:28:00 -04:00
parent 97a3f52c63
commit 148cc8f713

View File

@ -52,11 +52,8 @@ func TestExchangeBasic(t *testing.T) {
eventq2, errq2 := exchange.Subscribe(ctx2)
t.Log("publish")
var wg sync.WaitGroup
wg.Add(1)
errChan := make(chan error)
go func() {
defer wg.Done()
defer close(errChan)
for _, event := range testevents {
if err := exchange.Publish(ctx, "/test", event); err != nil {
@ -69,7 +66,6 @@ func TestExchangeBasic(t *testing.T) {
}()
t.Log("waiting")
wg.Wait()
if err := <-errChan; err != nil {
t.Fatal(err)
}