MCPcopy Create free account
hub / github.com/github/gh-aw / TestShellJoinArgs

Function TestShellJoinArgs

pkg/workflow/shell_test.go:157–198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

155}
156
157func TestShellJoinArgs(t *testing.T) {
158 tests := []struct {
159 name string
160 input []string
161 expected string
162 }{
163 {
164 name: "simple arguments",
165 input: []string{"git", "status"},
166 expected: "git status",
167 },
168 {
169 name: "arguments with special characters",
170 input: []string{"--allow-tool", "shell(git add:*)", "--allow-tool", "shell(git commit:*)"},
171 expected: "--allow-tool 'shell(git add:*)' --allow-tool 'shell(git commit:*)'",
172 },
173 {
174 name: "mixed arguments",
175 input: []string{"copilot", "--add-dir", "/tmp/gh-aw/", "--allow-tool", "shell(*.txt)"},
176 expected: "copilot --add-dir /tmp/gh-aw/ --allow-tool 'shell(*.txt)'",
177 },
178 {
179 name: "prompt with pre-quoted instruction is now properly escaped by shellJoinArgs",
180 input: []string{"copilot", "--add-dir", "/tmp/gh-aw/", "--prompt", "\"$INSTRUCTION\""},
181 expected: "copilot --add-dir /tmp/gh-aw/ --prompt '\"$INSTRUCTION\"'",
182 },
183 {
184 name: "allow-domains with GitHub Actions expression uses double quotes",
185 input: []string{"--allow-domains", "${{ env.MCP_ENV == 'staging' && env.MCP_URL_STAGING || env.MCP_URL_PROD }},errors.code.visualstudio.com"},
186 expected: `--allow-domains "${{ env.MCP_ENV == 'staging' && env.MCP_URL_STAGING || env.MCP_URL_PROD }},errors.code.visualstudio.com"`,
187 },
188 }
189
190 for _, tt := range tests {
191 t.Run(tt.name, func(t *testing.T) {
192 result := shellJoinArgs(tt.input)
193 if result != tt.expected {
194 t.Errorf("shellJoinArgs(%q) = %q, expected %q", tt.input, result, tt.expected)
195 }
196 })
197 }
198}
199
200func TestBuildDockerCommandWithExpandableVars(t *testing.T) {
201 tests := []struct {

Callers

nothing calls this directly

Calls 3

shellJoinArgsFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected