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

Function TestDetectFromCustomSteps

pkg/workflow/runtime_setup_test.go:162–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

160}
161
162func TestDetectFromCustomSteps(t *testing.T) {
163 tests := []struct {
164 name string
165 customSteps string
166 expected []string
167 skipIfHasSetup bool
168 }{
169 {
170 name: "detects node from npm command",
171 customSteps: `steps:
172 - run: npm install`,
173 expected: []string{"node"},
174 },
175 {
176 name: "detects python from python command",
177 customSteps: `steps:
178 - run: python test.py`,
179 expected: []string{"python"},
180 },
181 {
182 name: "detects multiple runtimes",
183 customSteps: `steps:
184 - run: npm install
185 - run: python test.py`,
186 expected: []string{"node", "python"},
187 },
188 {
189 name: "detects gh-aw from gh aw command",
190 customSteps: `steps:
191 - run: gh aw add githubnext/agentics`,
192 expected: []string{"gh-aw"},
193 },
194 {
195 name: "detects node even when setup-node exists (filtering happens later)",
196 customSteps: `steps:
197 - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f
198 - run: npm install`,
199 expected: []string{"node"}, // Changed: now detects, filtering happens in DetectRuntimeRequirements
200 },
201 }
202
203 for _, tt := range tests {
204 t.Run(tt.name, func(t *testing.T) {
205 requirements := make(map[string]*RuntimeRequirement)
206 detectFromCustomSteps(tt.customSteps, requirements)
207
208 if len(requirements) != len(tt.expected) {
209 t.Errorf("Expected %d requirements, got %d: %v", len(tt.expected), len(requirements), getRequirementIDs(requirements))
210 }
211
212 for _, expectedID := range tt.expected {
213 if _, exists := requirements[expectedID]; !exists {
214 t.Errorf("Expected runtime %s to be detected", expectedID)
215 }
216 }
217 })
218 }
219}

Callers

nothing calls this directly

Calls 4

detectFromCustomStepsFunction · 0.85
getRequirementIDsFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected