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

Function validateTriggerIR

pkg/workflow/trigger_parser_fuzz_test.go:303–363  ·  view source on GitHub ↗

validateTriggerIR validates that a TriggerIR structure is well-formed

(t *testing.T, ir *TriggerIR, input string)

Source from the content-addressed store, hash-verified

301
302// validateTriggerIR validates that a TriggerIR structure is well-formed
303func validateTriggerIR(t *testing.T, ir *TriggerIR, input string) {
304 // Event should be from the expected set of GitHub Actions events
305 validEvents := map[string]bool{
306 "push": true,
307 "pull_request": true,
308 "issues": true,
309 "discussion": true,
310 "release": true,
311 "watch": true,
312 "fork": true,
313 "issue_comment": true,
314 "workflow_run": true,
315 "repository_dispatch": true,
316 "code_scanning_alert": true,
317 "": true, // Empty is valid for manual-only triggers
318 }
319
320 if !validEvents[ir.Event] {
321 t.Errorf("TriggerIR has unexpected event type %q for input: %q", ir.Event, input)
322 }
323
324 // Types should not contain empty strings
325 for i, typ := range ir.Types {
326 if typ == "" {
327 t.Errorf("TriggerIR.Types[%d] is empty for input: %q", i, input)
328 }
329 }
330
331 // Filters should be a valid map
332 if ir.Filters != nil {
333 for key, value := range ir.Filters {
334 if key == "" {
335 t.Errorf("TriggerIR.Filters has empty key for input: %q", input)
336 }
337 if value == nil {
338 t.Errorf("TriggerIR.Filters[%q] is nil for input: %q", key, input)
339 }
340 }
341 }
342
343 // Conditions should not contain empty strings
344 for i, cond := range ir.Conditions {
345 if cond == "" {
346 t.Errorf("TriggerIR.Conditions[%d] is empty for input: %q", i, input)
347 }
348 }
349
350 // AdditionalEvents should be a valid map
351 if ir.AdditionalEvents != nil {
352 for key := range ir.AdditionalEvents {
353 if key == "" {
354 t.Errorf("TriggerIR.AdditionalEvents has empty key for input: %q", input)
355 }
356 }
357 }
358
359 // Validate that if Event is empty, AdditionalEvents should have something
360 if ir.Event == "" && len(ir.AdditionalEvents) == 0 {

Callers 1

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected