Skip to content

Commit

Permalink
Declare err inside the scope of each test
Browse files Browse the repository at this point in the history
  • Loading branch information
lattwood committed Jan 14, 2025
1 parent c848c33 commit bec8ffe
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions deadlock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,8 @@ func TestTimeoutParallel(t *testing.T) {
go func() {
wg.Add(1)
defer wg.Done()
streamAserver, err := serverSes.Open()
if err != nil {
t.Fatalf("server open stream A: %v", err)
}
err = monotonicWriter(t, streamAserver, "A", pauseA)
streamAserver, _ := serverSes.Open()
err := monotonicWriter(t, streamAserver, "A", pauseA)
if err != nil && !errors.Is(err, ErrStreamClosed) {
failNow(errCh, "[A-writer-server] received unexpected error", err)
}
Expand All @@ -180,7 +177,7 @@ func TestTimeoutParallel(t *testing.T) {
defer wg.Done()
streamAclient, _ := clientSes.Accept()
defer streamAclient.Close()
err = monotonicReader(t, streamAclient, "A")
err := monotonicReader(t, streamAclient, "A")
if err != nil && !errors.Is(err, io.EOF) {
failNow(errCh, "[A-reader-client] received unexpected error", err)
}
Expand All @@ -191,7 +188,7 @@ func TestTimeoutParallel(t *testing.T) {
wg.Add(1)
defer wg.Done()
streamBserver, _ := serverSes.Open()
err = monotonicWriter(t, streamBserver, "B", nil)
err := monotonicWriter(t, streamBserver, "B", nil)
if err != nil && !errors.Is(err, ErrConnectionWriteTimeout) {
failNow(errCh, "[B-writer-server] received unexpected error", err)
}
Expand All @@ -203,7 +200,7 @@ func TestTimeoutParallel(t *testing.T) {
defer wg.Done()
streamBclient, _ := clientSes.Accept()
defer streamBclient.Close()
err = monotonicReader(t, streamBclient, "B")
err := monotonicReader(t, streamBclient, "B")
if err != nil && !errors.Is(err, io.EOF) {
failNow(errCh, "[B-reader-client] received unexpected error", err)
}
Expand Down

0 comments on commit bec8ffe

Please sign in to comment.