@@ -79,8 +79,10 @@ func TestSocketPath_VMDetection(t *testing.T) {
7979 require .NoError (t , os .MkdirAll (filepath .Dir (colimaSock ), 0o755 ))
8080 f , err := os .Create (colimaSock )
8181 require .NoError (t , err )
82- f .Close ()
83- defer os .Remove (colimaSock )
82+ require .NoError (t , f .Close ())
83+ t .Cleanup (func () {
84+ require .NoError (t , os .Remove (colimaSock ))
85+ })
8486
8587 cli , err := client .NewClientWithOpts (client .WithHost ("unix://" + colimaSock ))
8688 require .NoError (t , err )
@@ -93,8 +95,10 @@ func TestSocketPath_VMDetection(t *testing.T) {
9395 require .NoError (t , os .MkdirAll (filepath .Dir (orbstackSock ), 0o755 ))
9496 f , err := os .Create (orbstackSock )
9597 require .NoError (t , err )
96- f .Close ()
97- defer os .Remove (orbstackSock )
98+ require .NoError (t , f .Close ())
99+ t .Cleanup (func () {
100+ require .NoError (t , os .Remove (orbstackSock ))
101+ })
98102
99103 cli , err := client .NewClientWithOpts (client .WithHost ("unix://" + orbstackSock ))
100104 require .NoError (t , err )
@@ -106,7 +110,9 @@ func TestSocketPath_VMDetection(t *testing.T) {
106110 // Use a non-VM socket path (short path to avoid Docker client limit)
107111 rootlessSock := "/tmp/lstk-docker.sock"
108112 require .NoError (t , os .WriteFile (rootlessSock , nil , 0o600 ))
109- defer os .Remove (rootlessSock )
113+ t .Cleanup (func () {
114+ require .NoError (t , os .Remove (rootlessSock ))
115+ })
110116
111117 cli , err := client .NewClientWithOpts (client .WithHost ("unix://" + rootlessSock ))
112118 require .NoError (t , err )
0 commit comments