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

Function TestAppendEnvVarLine

pkg/workflow/engine_helpers_test.go:500–600  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

498}
499
500func TestAppendEnvVarLine(t *testing.T) {
501 tests := []struct {
502 name string
503 key string
504 value string
505 expectedContent []string
506 notExpected []string
507 }{
508 {
509 name: "single-line value emitted inline",
510 key: "MY_VAR",
511 value: "simple value",
512 expectedContent: []string{
513 " MY_VAR: simple value",
514 },
515 },
516 {
517 name: "github expression emitted inline without extra quoting",
518 key: "TOKEN",
519 value: "${{ secrets.TOKEN }}",
520 expectedContent: []string{
521 " TOKEN: ${{ secrets.TOKEN }}",
522 },
523 },
524 {
525 name: "json value gets single-quoted inline",
526 key: "CONFIG",
527 value: `{"key":"value"}`,
528 expectedContent: []string{
529 ` CONFIG: '{"key":"value"}'`,
530 },
531 },
532 {
533 name: "multi-line value emitted as literal block scalar",
534 key: "COPILOT_GITHUB_TOKEN",
535 // Continuation lines have 4-space leading whitespace (as produced by goccy/go-yaml
536 // when parsing a >- block scalar with extra-indented continuation lines).
537 value: "${{ secrets.PAT_1 != '' && secrets.PAT_1 ||\n secrets.PAT_2 }}",
538 expectedContent: []string{
539 " COPILOT_GITHUB_TOKEN: |",
540 " ${{ secrets.PAT_1 != '' && secrets.PAT_1 ||",
541 // Continuation line has 4-space prefix preserved: 12 base + 4 continuation = 16 spaces total.
542 " secrets.PAT_2 }}",
543 },
544 notExpected: []string{
545 "COPILOT_GITHUB_TOKEN: ${{ secrets.PAT_1",
546 },
547 },
548 {
549 name: "trailing newline is trimmed before deciding inline vs block",
550 key: "TRIMMED",
551 value: "${{ secrets.TOKEN }}\n",
552 expectedContent: []string{
553 " TRIMMED: ${{ secrets.TOKEN }}",
554 },
555 notExpected: []string{
556 "TRIMMED: |",
557 },

Callers

nothing calls this directly

Calls 3

appendEnvVarLineFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected