Skip to content

Commit

Permalink
Merge pull request #1601 from alrs/fix-test-goroutine
Browse files Browse the repository at this point in the history
fix: remove use of testing.T.FailNow() inside goroutine
  • Loading branch information
bai authored Feb 6, 2020
2 parents b3a8121 + e5ac353 commit 9d2cdb2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,13 +830,11 @@ func TestClientAutorefreshShutdownRace(t *testing.T) {
// Wait for the background refresh to kick in
time.Sleep(110 * time.Millisecond)

done := make(chan none)
errCh := make(chan error, 1)
go func() {
// Close the client
if err := client.Close(); err != nil {
t.Fatal(err)
}
close(done)
errCh <- client.Close()
close(errCh)
}()

// Wait for the Close to kick in
Expand All @@ -848,7 +846,10 @@ func TestClientAutorefreshShutdownRace(t *testing.T) {
metadataResponse.AddTopicPartition("foo", 0, leader.BrokerID(), []int32{2}, []int32{2}, []int32{}, ErrNoError)
seedBroker.Returns(metadataResponse)

<-done
err = <-errCh
if err != nil {
t.Fatalf("goroutine client.Close():%s", err)
}

seedBroker.Close()

Expand Down

0 comments on commit 9d2cdb2

Please sign in to comment.