Skip to content

Commit

Permalink
fix(routing/mock): wait for goroutine cleanup (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Jun 19, 2024
1 parent 1fccf46 commit aaf9a04
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion routing/mock/centralized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mockrouting

import (
"context"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -87,7 +88,12 @@ func TestCanceledContext(t *testing.T) {
// (we want the goroutine to keep trying to publish on a
// cancelled context until we've tested it doesnt do anything.)
done := make(chan struct{})
defer func() { done <- struct{}{} }()
doneWg := sync.WaitGroup{}
doneWg.Add(1)
defer func() {
done <- struct{}{}
doneWg.Wait()
}()

t.Log("async'ly announce infinite stream of providers for key")
i := 0
Expand All @@ -96,6 +102,7 @@ func TestCanceledContext(t *testing.T) {
select {
case <-done:
t.Log("exiting async worker")
doneWg.Done()
return
default:
}
Expand Down

0 comments on commit aaf9a04

Please sign in to comment.