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

Function TestHelperFunctions

pkg/workflow/expressions_test.go:472–519  ·  view source on GitHub ↗

TestHelperFunctions tests the helper functions for building expressions

(t *testing.T)

Source from the content-addressed store, hash-verified

470
471// TestHelperFunctions tests the helper functions for building expressions
472func 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
522func TestConvenienceHelpers(t *testing.T) {

Callers

nothing calls this directly

Calls 8

BuildPropertyAccessFunction · 0.85
BuildStringLiteralFunction · 0.85
BuildBooleanLiteralFunction · 0.85
BuildEqualsFunction · 0.85
BuildFunctionCallFunction · 0.85
RenderMethod · 0.65
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected