@@ -109,11 +109,9 @@ func TestDevcontainerCLI_ArgsAndParsing(t *testing.T) {
109
109
110
110
testExecer := & testDevcontainerExecer {
111
111
testExePath : testExePath ,
112
- extraEnv : []string {
113
- "TEST_DEVCONTAINER_WANT_ARGS=" + tt .wantArgs ,
114
- "TEST_DEVCONTAINER_WANT_ERROR=" + fmt .Sprintf ("%v" , tt .wantError ),
115
- "TEST_DEVCONTAINER_LOG_FILE=" + filepath .Join ("testdata" , "devcontainercli" , "parse" , tt .logFile ),
116
- },
112
+ wantArgs : tt .wantArgs ,
113
+ wantError : tt .wantError ,
114
+ logFile : filepath .Join ("testdata" , "devcontainercli" , "parse" , tt .logFile ),
117
115
}
118
116
119
117
dccli := agentcontainers .NewDevcontainerCLI (logger , testExecer )
@@ -133,7 +131,9 @@ func TestDevcontainerCLI_ArgsAndParsing(t *testing.T) {
133
131
// testDevcontainerExecer implements the agentexec.Execer interface for testing.
134
132
type testDevcontainerExecer struct {
135
133
testExePath string
136
- extraEnv []string
134
+ wantArgs string
135
+ wantError bool
136
+ logFile string
137
137
}
138
138
139
139
// CommandContext returns a test binary command that simulates devcontainer responses.
@@ -155,9 +155,13 @@ func (e *testDevcontainerExecer) CommandContext(ctx context.Context, name string
155
155
156
156
//nolint:gosec // This is a test binary, so we don't need to worry about command injection.
157
157
cmd := exec .CommandContext (ctx , e .testExePath , testArgs ... )
158
- cmd .Env = append (os .Environ (), e .extraEnv ... )
159
- // Set this environment va[riable so the child process knows it's the helper.
160
- cmd .Env = append (cmd .Env , "TEST_DEVCONTAINER_WANT_HELPER_PROCESS=1" )
158
+ // Set this environment variable so the child process knows it's the helper.
159
+ cmd .Env = append (os .Environ (),
160
+ "TEST_DEVCONTAINER_WANT_HELPER_PROCESS=1" ,
161
+ "TEST_DEVCONTAINER_WANT_ARGS=" + e .wantArgs ,
162
+ "TEST_DEVCONTAINER_WANT_ERROR=" + fmt .Sprintf ("%v" , e .wantError ),
163
+ "TEST_DEVCONTAINER_LOG_FILE=" + e .logFile ,
164
+ )
161
165
162
166
return cmd
163
167
}
0 commit comments