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

Function TestWorkflowDispatchInjection

pkg/workflow/trial_issue_mode_test.go:75–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestWorkflowDispatchInjection(t *testing.T) {
76 compiler := NewCompiler()
77
78 testCases := []struct {
79 name string
80 onSection string
81 expected string
82 }{
83 {
84 name: "Simple issues trigger",
85 onSection: `on:
86 issues:
87 types: [opened, edited]`,
88 expected: "workflow_dispatch:",
89 },
90 {
91 name: "Complex triggers with issues",
92 onSection: `on:
93 push:
94 branches: [main]
95 issues:
96 types: [opened]
97 pull_request:`,
98 expected: "workflow_dispatch:",
99 },
100 }
101
102 for _, tc := range testCases {
103 t.Run(tc.name, func(t *testing.T) {
104 result := compiler.injectWorkflowDispatchForIssue(tc.onSection)
105 if !strings.Contains(result, tc.expected) {
106 t.Errorf("injectWorkflowDispatchForIssue() result does not contain %s\nGot: %s", tc.expected, result)
107 }
108 // Check that issue_number input is added
109 if !strings.Contains(result, "issue_number") {
110 t.Errorf("injectWorkflowDispatchForIssue() result does not contain issue_number input")
111 }
112 })
113 }
114}
115
116func TestIssueNumberReplacement(t *testing.T) {
117 compiler := NewCompiler()

Callers

nothing calls this directly

Calls 4

NewCompilerFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected