diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-09-16 15:09:58 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-09-20 17:22:32 +0300 |
commit | 4d6bbe3774f7c926ad655a26336ff093f1a7a32b (patch) | |
tree | 6f5f7289b0d4085b2557dac16daba4cb1a17bcbf | |
parent | 821df9c3f9a67d147f8603887559e24944d1afe3 (diff) |
bootstrap: Start to use new `net.ErrClosed` error type
With Go 1.16, it is now possible to detect closed connection via the new
`net.ErrClosed` error type. Adapt the bootstrap test to use this type
instead of doing a string comparison.
-rw-r--r-- | internal/bootstrap/bootstrap_test.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/internal/bootstrap/bootstrap_test.go b/internal/bootstrap/bootstrap_test.go index fce265679..a809f46f0 100644 --- a/internal/bootstrap/bootstrap_test.go +++ b/internal/bootstrap/bootstrap_test.go @@ -2,6 +2,7 @@ package bootstrap import ( "context" + "errors" "fmt" "io/ioutil" "net" @@ -113,7 +114,7 @@ func TestImmediateTerminationOnSocketError(t *testing.T) { err := waitWithTimeout(t, waitCh, 1*time.Second) require.Error(t, err) - require.Contains(t, err.Error(), "use of closed network connection") + require.True(t, errors.Is(err, net.ErrClosed), "expected closed connection error, got %T: %q", err, err) } func TestImmediateTerminationOnSignal(t *testing.T) { |