TestHelperFunctionsForMultiline tests the new helper functions
(t *testing.T)
| 704 | |
| 705 | // TestHelperFunctionsForMultiline tests the new helper functions |
| 706 | func TestHelperFunctionsForMultiline(t *testing.T) { |
| 707 | t.Run("BuildDisjunction with multiline", func(t *testing.T) { |
| 708 | term1 := &ExpressionNode{Expression: "github.event_name == 'issues'", Description: "Handle issue events"} |
| 709 | term2 := &ExpressionNode{Expression: "github.event_name == 'pull_request'", Description: "Handle PR events"} |
| 710 | |
| 711 | disjunction := BuildDisjunction(true, term1, term2) |
| 712 | |
| 713 | if !disjunction.Multiline { |
| 714 | t.Error("Expected Multiline to be true") |
| 715 | } |
| 716 | |
| 717 | expected := "# Handle issue events\ngithub.event_name == 'issues' ||\n# Handle PR events\ngithub.event_name == 'pull_request'" |
| 718 | if result := disjunction.Render(); result != expected { |
| 719 | t.Errorf("Expected '%s', got '%s'", expected, result) |
| 720 | } |
| 721 | }) |
| 722 | |
| 723 | t.Run("BuildDisjunction with single term", func(t *testing.T) { |
| 724 | term := &ExpressionNode{Expression: "github.event_name == 'issues'", Description: "Handle issue events"} |
| 725 | |
| 726 | // Test with multiline=false |
| 727 | disjunctionSingle := BuildDisjunction(false, term) |
| 728 | expected := "github.event_name == 'issues'" |
| 729 | if result := disjunctionSingle.Render(); result != expected { |
| 730 | t.Errorf("Expected '%s', got '%s'", expected, result) |
| 731 | } |
| 732 | |
| 733 | // Test with multiline=true - should still render as single term without OR |
| 734 | disjunctionMulti := BuildDisjunction(true, term) |
| 735 | if result := disjunctionMulti.Render(); result != expected { |
| 736 | t.Errorf("Expected '%s', got '%s'", expected, result) |
| 737 | } |
| 738 | }) |
| 739 | } |
| 740 | |
| 741 | func TestBuildNotFromFork(t *testing.T) { |
| 742 | result := BuildNotFromFork() |
nothing calls this directly
no test coverage detected