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

Function TestEscapeBareShellDollarSigns

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

Source from the content-addressed store, hash-verified

311}
312
313func TestEscapeBareShellDollarSigns(t *testing.T) {
314 tests := []struct {
315 name string
316 input string
317 expected string
318 }{
319 {
320 name: "empty string",
321 input: "",
322 expected: "",
323 },
324 {
325 name: "no dollar signs",
326 input: "no dollars here",
327 expected: "no dollars here",
328 },
329 {
330 name: "bare dollar followed by identifier",
331 input: "$schema",
332 expected: `\$schema`,
333 },
334 {
335 name: "dollar sign at end of string",
336 input: "trailing$",
337 expected: `trailing\$`,
338 },
339 {
340 name: "GitHub Actions expression is preserved",
341 input: "${{ env.DOMAINS }}",
342 expected: "${{ env.DOMAINS }}",
343 },
344 {
345 name: "multiple GitHub Actions expressions are preserved",
346 input: "${{ env.A }},${{ env.B }}",
347 expected: "${{ env.A }},${{ env.B }}",
348 },
349 {
350 name: "bare dollar mixed with GitHub Actions expression",
351 input: `$schema and ${{ env.X }}`,
352 expected: `\$schema and ${{ env.X }}`,
353 },
354 {
355 name: "JSON $schema key alongside expression",
356 input: `{"$schema":"https://example.com","allowDomains":["${{ env.DOMAINS }}"]}`,
357 expected: `{"\$schema":"https://example.com","allowDomains":["${{ env.DOMAINS }}"]}`,
358 },
359 {
360 name: "dollar followed by single open brace is escaped",
361 input: "${HOME}",
362 expected: `\${HOME}`,
363 },
364 {
365 name: "dollar followed by ${{ is preserved",
366 input: "${{",
367 expected: "${{",
368 },
369 }
370

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected