diff --git a/v2/internal/test/fakeworkloadapi/workload_api.go b/v2/internal/test/fakeworkloadapi/workload_api.go index 0668545..fdfefb3 100644 --- a/v2/internal/test/fakeworkloadapi/workload_api.go +++ b/v2/internal/test/fakeworkloadapi/workload_api.go @@ -50,7 +50,7 @@ func New(tb testing.TB) *WorkloadAPI { x509BundlesChans: make(map[chan *workload.X509BundlesResponse]struct{}), } - listener, err := newListener() + listener, err := newListener(tb) require.NoError(tb, err) server := grpc.NewServer() diff --git a/v2/internal/test/fakeworkloadapi/workload_api_posix.go b/v2/internal/test/fakeworkloadapi/workload_api_posix.go index 8572e33..473966d 100644 --- a/v2/internal/test/fakeworkloadapi/workload_api_posix.go +++ b/v2/internal/test/fakeworkloadapi/workload_api_posix.go @@ -6,9 +6,10 @@ package fakeworkloadapi import ( "fmt" "net" + "testing" ) -func newListener() (net.Listener, error) { +func newListener(_ testing.TB) (net.Listener, error) { return net.Listen("tcp", "localhost:0") } diff --git a/v2/internal/test/fakeworkloadapi/workload_api_windows.go b/v2/internal/test/fakeworkloadapi/workload_api_windows.go index ce011b1..acf46b3 100644 --- a/v2/internal/test/fakeworkloadapi/workload_api_windows.go +++ b/v2/internal/test/fakeworkloadapi/workload_api_windows.go @@ -23,7 +23,7 @@ func NewWithNamedPipeListener(tb testing.TB) *WorkloadAPI { jwtBundlesChans: make(map[chan *workload.JWTBundlesResponse]struct{}), } - listener, err := winio.ListenPipe(fmt.Sprintf(`\\.\pipe\go-spiffe-test-pipe-%x`, randUint64()), nil) + listener, err := winio.ListenPipe(fmt.Sprintf(`\\.\pipe\go-spiffe-test-pipe-%x`, randUint64(tb)), nil) require.NoError(tb, err) server := grpc.NewServer() @@ -54,8 +54,8 @@ func randUint64(t testing.TB) uint64 { return n.Uint64() } -func newListener() (net.Listener, error) { - return winio.ListenPipe(fmt.Sprintf(`\\.\pipe\go-spiffe-test-pipe-%x`, randUint64()), nil) +func newListener(tb testing.TB) (net.Listener, error) { + return winio.ListenPipe(fmt.Sprintf(`\\.\pipe\go-spiffe-test-pipe-%x`, randUint64(tb)), nil) } func getTargetName(addr net.Addr) string {