@@ -47,7 +47,7 @@ volume = "` + escapeTomlPath(customVolume) + `"
4747 configFile := filepath .Join (t .TempDir (), "config.toml" )
4848 require .NoError (t , os .WriteFile (configFile , []byte (configContent ), 0644 ))
4949
50- stdout , stderr , err := runLstk (t , testContext (t ), t .TempDir (), os . Environ ( ), "--config" , configFile , "volume" , "path" )
50+ stdout , stderr , err := runLstk (t , testContext (t ), t .TempDir (), testEnvWithHome ( t . TempDir (), "" ), "--config" , configFile , "volume" , "path" )
5151 require .NoError (t , err , stderr )
5252 requireExitCode (t , 0 , err )
5353
@@ -90,7 +90,7 @@ volume = "` + escapeTomlPath(volumeDir) + `"
9090 configFile := filepath .Join (t .TempDir (), "config.toml" )
9191 require .NoError (t , os .WriteFile (configFile , []byte (configContent ), 0644 ))
9292
93- stdout , stderr , err := runLstk (t , testContext (t ), t .TempDir (), os . Environ ( ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" )
93+ stdout , stderr , err := runLstk (t , testContext (t ), t .TempDir (), testEnvWithHome ( t . TempDir (), "" ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" )
9494 require .NoError (t , err , "lstk volume clear failed: %s\n stdout: %s" , stderr , stdout )
9595 requireExitCode (t , 0 , err )
9696
@@ -135,7 +135,7 @@ volume = "` + escapeTomlPath(volumeDir) + `"
135135 configFile := filepath .Join (t .TempDir (), "config.toml" )
136136 require .NoError (t , os .WriteFile (configFile , []byte (configContent ), 0644 ))
137137
138- stdout , stderr , err := runLstk (t , testContext (t ), t .TempDir (), os . Environ ( ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" )
138+ stdout , stderr , err := runLstk (t , testContext (t ), t .TempDir (), testEnvWithHome ( t . TempDir (), "" ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" )
139139 require .NoError (t , err , "lstk volume clear failed: %s\n stdout: %s" , stderr , stdout )
140140 requireExitCode (t , 0 , err )
141141
@@ -158,13 +158,13 @@ volume = "` + escapeTomlPath(volumeDir) + `"
158158 require .NoError (t , os .WriteFile (configFile , []byte (configContent ), 0644 ))
159159
160160 // Wrong type should fail
161- _ , stderr , err := runLstk (t , testContext (t ), t .TempDir (), os . Environ ( ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" , "--type" , "snowflake" )
161+ _ , stderr , err := runLstk (t , testContext (t ), t .TempDir (), testEnvWithHome ( t . TempDir (), "" ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" , "--type" , "snowflake" )
162162 require .Error (t , err )
163163 requireExitCode (t , 1 , err )
164164 assert .Contains (t , stderr , "not found" )
165165
166166 // Correct type should succeed
167- stdout , stderr , err := runLstk (t , testContext (t ), t .TempDir (), os . Environ ( ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" , "--type" , "aws" )
167+ stdout , stderr , err := runLstk (t , testContext (t ), t .TempDir (), testEnvWithHome ( t . TempDir (), "" ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" , "--type" , "aws" )
168168 require .NoError (t , err , "lstk volume clear failed: %s\n stdout: %s" , stderr , stdout )
169169 requireExitCode (t , 0 , err )
170170
@@ -223,7 +223,7 @@ volume = "` + escapeTomlPath(volumeDir) + `"
223223 configFile := filepath .Join (t .TempDir (), "config.toml" )
224224 require .NoError (t , os .WriteFile (configFile , []byte (configContent ), 0644 ))
225225
226- _ , stderr , err := runLstk (t , testContext (t ), t .TempDir (), os . Environ ( ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" )
226+ _ , stderr , err := runLstk (t , testContext (t ), t .TempDir (), testEnvWithHome ( t . TempDir (), "" ), "--config" , configFile , "--non-interactive" , "volume" , "clear" , "--force" )
227227 if err == nil {
228228 t .Skip ("Docker is configured with user namespace remapping; root-owned files cleared without issue" )
229229 }
@@ -258,7 +258,7 @@ volume = "` + escapeTomlPath(volumeDir) + `"
258258 startVolumeClear := func (t * testing.T , configFile string ) (* os.File , * syncBuffer , chan struct {}, * exec.Cmd ) {
259259 t .Helper ()
260260 cmd := exec .CommandContext (testContext (t ), binaryPath (), "--config" , configFile , "volume" , "clear" )
261- cmd .Env = os . Environ ( )
261+ cmd .Env = testEnvWithHome ( t . TempDir (), "" )
262262 ptmx , err := pty .Start (cmd )
263263 require .NoError (t , err , "failed to start command in PTY" )
264264 t .Cleanup (func () { _ = ptmx .Close () })
0 commit comments