TestHelperFunctions tests the helper functions for building expressions
(t *testing.T)
| 470 | |
| 471 | // TestHelperFunctions tests the helper functions for building expressions |
| 472 | func TestHelperFunctions(t *testing.T) { |
| 473 | t.Run("BuildPropertyAccess", func(t *testing.T) { |
| 474 | node := BuildPropertyAccess("github.event.action") |
| 475 | expected := "github.event.action" |
| 476 | if result := node.Render(); result != expected { |
| 477 | t.Errorf("Expected '%s', got '%s'", expected, result) |
| 478 | } |
| 479 | }) |
| 480 | |
| 481 | t.Run("BuildStringLiteral", func(t *testing.T) { |
| 482 | node := BuildStringLiteral("opened") |
| 483 | expected := "'opened'" |
| 484 | if result := node.Render(); result != expected { |
| 485 | t.Errorf("Expected '%s', got '%s'", expected, result) |
| 486 | } |
| 487 | }) |
| 488 | |
| 489 | t.Run("BuildBooleanLiteral", func(t *testing.T) { |
| 490 | node := BuildBooleanLiteral(true) |
| 491 | expected := "true" |
| 492 | if result := node.Render(); result != expected { |
| 493 | t.Errorf("Expected '%s', got '%s'", expected, result) |
| 494 | } |
| 495 | }) |
| 496 | |
| 497 | t.Run("BuildEquals", func(t *testing.T) { |
| 498 | node := BuildEquals( |
| 499 | BuildPropertyAccess("github.event.action"), |
| 500 | BuildStringLiteral("opened"), |
| 501 | ) |
| 502 | expected := "github.event.action == 'opened'" |
| 503 | if result := node.Render(); result != expected { |
| 504 | t.Errorf("Expected '%s', got '%s'", expected, result) |
| 505 | } |
| 506 | }) |
| 507 | |
| 508 | t.Run("BuildFunctionCall", func(t *testing.T) { |
| 509 | node := BuildFunctionCall("startsWith", |
| 510 | BuildPropertyAccess("github.ref"), |
| 511 | BuildStringLiteral("refs/heads/"), |
| 512 | ) |
| 513 | expected := "startsWith(github.ref, 'refs/heads/')" |
| 514 | if result := node.Render(); result != expected { |
| 515 | t.Errorf("Expected '%s', got '%s'", expected, result) |
| 516 | } |
| 517 | }) |
| 518 | |
| 519 | } |
| 520 | |
| 521 | // TestConvenienceHelpers tests the convenience helper functions |
| 522 | func TestConvenienceHelpers(t *testing.T) { |
nothing calls this directly
no test coverage detected