Skip to content

Commit

Permalink
Use assert.ErrorContains for error matching
Browse files Browse the repository at this point in the history
Signed-off-by: Noble Mittal <[email protected]>
  • Loading branch information
beingnoble03 committed Mar 4, 2024
1 parent 8fce031 commit fda1a9b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions go/netutil/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package netutil

import (
"net"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -73,9 +72,7 @@ func TestReadTimeout(t *testing.T) {

select {
case err := <-c:
assert.Error(t, err)

assert.True(t, strings.HasSuffix(err.Error(), "i/o timeout"), "Expected error timeout, got %s", err)
assert.ErrorContains(t, err, "i/o timeout", "Expected error timeout")
case <-time.After(10 * time.Second):
t.Errorf("Timeout did not happen")
}
Expand Down Expand Up @@ -105,9 +102,7 @@ func TestWriteTimeout(t *testing.T) {

select {
case err := <-c:
assert.Error(t, err)

assert.True(t, strings.HasSuffix(err.Error(), "i/o timeout"), "Expected error timeout, got %s", err)
assert.ErrorContains(t, err, "i/o timeout", "Expected error timeout")
case <-time.After(10 * time.Second):
t.Errorf("Timeout did not happen")
}
Expand Down

0 comments on commit fda1a9b

Please sign in to comment.