(t *testing.T)
| 378 | } |
| 379 | |
| 380 | func TestYamlStringValue(t *testing.T) { |
| 381 | tests := []struct { |
| 382 | name string |
| 383 | input string |
| 384 | expected string |
| 385 | }{ |
| 386 | { |
| 387 | name: "plain string unchanged", |
| 388 | input: "hello world", |
| 389 | expected: "hello world", |
| 390 | }, |
| 391 | { |
| 392 | name: "empty string unchanged", |
| 393 | input: "", |
| 394 | expected: "", |
| 395 | }, |
| 396 | { |
| 397 | name: "github actions expression unchanged", |
| 398 | input: "${{ secrets.TOKEN }}", |
| 399 | expected: "${{ secrets.TOKEN }}", |
| 400 | }, |
| 401 | { |
| 402 | name: "json object gets single-quoted", |
| 403 | input: `{"key":"value"}`, |
| 404 | expected: `'{"key":"value"}'`, |
| 405 | }, |
| 406 | { |
| 407 | name: "json array gets single-quoted", |
| 408 | input: `["a","b"]`, |
| 409 | expected: `'["a","b"]'`, |
| 410 | }, |
| 411 | { |
| 412 | name: "json object with embedded single quote gets escaped", |
| 413 | input: `{"key":"it's"}`, |
| 414 | expected: `'{"key":"it''s"}'`, |
| 415 | }, |
| 416 | } |
| 417 | |
| 418 | for _, tt := range tests { |
| 419 | t.Run(tt.name, func(t *testing.T) { |
| 420 | result := yamlStringValue(tt.input) |
| 421 | if result != tt.expected { |
| 422 | t.Errorf("yamlStringValue(%q) = %q, want %q", tt.input, result, tt.expected) |
| 423 | } |
| 424 | }) |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | func TestFormatStepWithCommandAndEnvYAMLSafe(t *testing.T) { |
| 429 | t.Run("json env var is single-quoted for valid YAML", func(t *testing.T) { |
nothing calls this directly
no test coverage detected