@@ -80,8 +80,10 @@ func TestSocketPath_VMDetection(t *testing.T) {
8080 require .NoError (t , os .MkdirAll (filepath .Dir (colimaSock ), 0o755 ))
8181 f , err := os .Create (colimaSock )
8282 require .NoError (t , err )
83- f .Close ()
84- defer os .Remove (colimaSock )
83+ require .NoError (t , f .Close ())
84+ t .Cleanup (func () {
85+ require .NoError (t , os .Remove (colimaSock ))
86+ })
8587
8688 cli , err := client .NewClientWithOpts (client .WithHost ("unix://" + colimaSock ))
8789 require .NoError (t , err )
@@ -94,8 +96,10 @@ func TestSocketPath_VMDetection(t *testing.T) {
9496 require .NoError (t , os .MkdirAll (filepath .Dir (orbstackSock ), 0o755 ))
9597 f , err := os .Create (orbstackSock )
9698 require .NoError (t , err )
97- f .Close ()
98- defer os .Remove (orbstackSock )
99+ require .NoError (t , f .Close ())
100+ t .Cleanup (func () {
101+ require .NoError (t , os .Remove (orbstackSock ))
102+ })
99103
100104 cli , err := client .NewClientWithOpts (client .WithHost ("unix://" + orbstackSock ))
101105 require .NoError (t , err )
@@ -107,7 +111,9 @@ func TestSocketPath_VMDetection(t *testing.T) {
107111 // Use a non-VM socket path (short path to avoid Docker client limit)
108112 rootlessSock := "/tmp/lstk-docker.sock"
109113 require .NoError (t , os .WriteFile (rootlessSock , nil , 0o600 ))
110- defer os .Remove (rootlessSock )
114+ t .Cleanup (func () {
115+ require .NoError (t , os .Remove (rootlessSock ))
116+ })
111117
112118 cli , err := client .NewClientWithOpts (client .WithHost ("unix://" + rootlessSock ))
113119 require .NoError (t , err )
0 commit comments