diff options
author | Valery Piashchynski <[email protected]> | 2021-08-13 10:51:23 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-08-13 10:51:23 +0300 |
commit | e17bb65ae70c47020eb40a798cf49f6e98ef3d5f (patch) | |
tree | de3bde1c477d7db1b3161ca069328b9c230b3f82 /pkg/transport | |
parent | 715c2931d578d8fa23a1497bb85cc120e8493dbd (diff) |
Add timeout to the Test_Tcp_StartError test
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg/transport')
-rwxr-xr-x | pkg/transport/socket/socket_factory_test.go | 8 |
1 files 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) } |