Skip to content

Commit

Permalink
Relax test assertions (#193)
Browse files Browse the repository at this point in the history
The current assertions are too coupled to the exact error message
produced by the Go net package internals, which can vary between
versions and platforms.

We don't really need this strong of an assertion. All we need to know is
that the Close() method was wired through appropriately.

Signed-off-by: Andrew Harding <aharding@vmware.com>
  • Loading branch information
azdagron committed Apr 27, 2022
1 parent 2ed460a commit aaec099
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions v2/spiffetls/spiffetls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,10 @@ func TestClose(t *testing.T) {

// If the connection was really closed, this should fail
_, err = conn.Write([]byte(dataString))
require.EqualError(t, err, "tls: use of closed connection")
require.Error(t, err)

// Connection has been closed already, expect error
require.EqualError(t, conn.Close(), "spiffetls: unable to close TLS connection: tls: use of closed connection")
require.Error(t, conn.Close())

// Close listener
require.NoError(t, listener.Close())
Expand All @@ -449,7 +449,7 @@ func TestClose(t *testing.T) {
require.Error(t, err)

// Listener has been closed already, expect error
require.Contains(t, listener.Close().Error(), "use of closed network connection")
require.Error(t, listener.Close())
}

func setWorkloadAPIResponse(ca *test.CA, s *fakeworkloadapi.WorkloadAPI, spiffeID spiffeid.ID) {
Expand Down

0 comments on commit aaec099

Please sign in to comment.