(t *testing.T)
| 458 | } |
| 459 | |
| 460 | func TestExpressionHelpers(t *testing.T) { |
| 461 | tests := []struct { |
| 462 | name string |
| 463 | input string |
| 464 | wantHasMarker bool |
| 465 | wantContainsExpr bool |
| 466 | wantWholeExprOnly bool |
| 467 | }{ |
| 468 | { |
| 469 | name: "full expression", |
| 470 | input: "${{ github.actor }}", |
| 471 | wantHasMarker: true, |
| 472 | wantContainsExpr: true, |
| 473 | wantWholeExprOnly: true, |
| 474 | }, |
| 475 | { |
| 476 | name: "embedded expression", |
| 477 | input: "prefix ${{ github.actor }} suffix", |
| 478 | wantHasMarker: true, |
| 479 | wantContainsExpr: true, |
| 480 | wantWholeExprOnly: false, |
| 481 | }, |
| 482 | { |
| 483 | name: "partial expression marker only", |
| 484 | input: "${{ github.actor", |
| 485 | wantHasMarker: true, |
| 486 | wantContainsExpr: false, |
| 487 | wantWholeExprOnly: false, |
| 488 | }, |
| 489 | { |
| 490 | name: "empty expression body", |
| 491 | input: "${{}}", |
| 492 | // isExpression is a strict wrapper check, while containsExpression |
| 493 | // requires a non-empty expression body between markers. |
| 494 | wantHasMarker: true, |
| 495 | wantContainsExpr: false, |
| 496 | wantWholeExprOnly: true, |
| 497 | }, |
| 498 | { |
| 499 | name: "wrong marker order", |
| 500 | input: "}} before ${{", |
| 501 | wantHasMarker: true, |
| 502 | wantContainsExpr: false, |
| 503 | wantWholeExprOnly: false, |
| 504 | }, |
| 505 | { |
| 506 | name: "no expression", |
| 507 | input: "plain text", |
| 508 | wantHasMarker: false, |
| 509 | wantContainsExpr: false, |
| 510 | wantWholeExprOnly: false, |
| 511 | }, |
| 512 | } |
| 513 | |
| 514 | for _, tt := range tests { |
| 515 | t.Run(tt.name, func(t *testing.T) { |
| 516 | assert.Equal(t, tt.wantHasMarker, hasExpressionMarker(tt.input), "hasExpressionMarker result mismatch") |
| 517 | assert.Equal(t, tt.wantContainsExpr, containsExpression(tt.input), "containsExpression result mismatch") |
nothing calls this directly
no test coverage detected