@@ -8405,6 +8405,8 @@ func TestRetentionAPI(t *testing.T) {
84058405 assert .NoError (t , err )
84068406 err = client .Chtimes (uploadPath , time .Now ().Add (- 48 * time .Hour ), time .Now ().Add (- 48 * time .Hour ))
84078407 assert .NoError (t , err )
8408+ conn .Close ()
8409+ client .Close ()
84088410 }
84098411
84108412 // remove delete permissions to the user, it will be automatically granted
@@ -8415,9 +8417,6 @@ func TestRetentionAPI(t *testing.T) {
84158417
84168418 conn , client , err = getSftpClient (user )
84178419 if assert .NoError (t , err ) {
8418- defer conn .Close ()
8419- defer client .Close ()
8420-
84218420 innerUploadFilePath := path .Join ("/" + testDir , testDir , testFileName )
84228421 err = client .Mkdir (path .Join (testDir , testDir ))
84238422 assert .NoError (t , err )
@@ -8482,6 +8481,8 @@ func TestRetentionAPI(t *testing.T) {
84828481
84838482 _ , err = client .Stat (innerUploadFilePath )
84848483 assert .ErrorIs (t , err , os .ErrNotExist )
8484+ conn .Close ()
8485+ client .Close ()
84858486 }
84868487 // finally test some errors removing files or folders
84878488 if runtime .GOOS != osWindows {
@@ -8553,6 +8554,10 @@ func TestRetentionAPI(t *testing.T) {
85538554 assert .NoError (t , err )
85548555 err = os .RemoveAll (user .GetHomeDir ())
85558556 assert .NoError (t , err )
8557+
8558+ assert .Eventually (t , func () bool {
8559+ return common .Connections .GetClientConnections () == 0
8560+ }, 1 * time .Second , 50 * time .Millisecond )
85568561}
85578562
85588563func TestPerUserTransferLimits (t * testing.T ) {
0 commit comments