From e17bb65ae70c47020eb40a798cf49f6e98ef3d5f Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Fri, 13 Aug 2021 10:51:23 +0300 Subject: Add timeout to the Test_Tcp_StartError test Signed-off-by: Valery Piashchynski --- pkg/transport/socket/socket_factory_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/transport/socket/socket_factory_test.go b/pkg/transport/socket/socket_factory_test.go index f9bb2178..17437e2f 100755 --- a/pkg/transport/socket/socket_factory_test.go +++ b/pkg/transport/socket/socket_factory_test.go @@ -78,7 +78,9 @@ func Test_Tcp_StartCloseFactory(t *testing.T) { func Test_Tcp_StartError(t *testing.T) { time.Sleep(time.Millisecond * 10) // to ensure free socket - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { @@ -97,7 +99,9 @@ func Test_Tcp_StartError(t *testing.T) { t.Errorf("error executing the command: error %v", err) } - w, err := NewSocketServer(ls, time.Minute).SpawnWorkerWithTimeout(ctx, cmd) + serv := NewSocketServer(ls, time.Minute) + time.Sleep(time.Second * 2) + w, err := serv.SpawnWorkerWithTimeout(ctx, cmd) assert.Error(t, err) assert.Nil(t, w) } -- cgit v1.2.3