-
Notifications
You must be signed in to change notification settings - Fork 57
Closed
Closed
Copy link
Description
Description
The validation file pkg/workflow/compiler_filters_validation.go has no test coverage despite being a validation-focused file. This is a critical gap for code that validates GitHub Actions requirements.
Problem
- Zero test coverage for validation logic
- File validates mutual exclusivity of event filters (branches vs branches-ignore, paths vs paths-ignore)
- Risk: Validation bugs may slip into production
- Cannot verify correctness of GitHub Actions requirement checks
Files Affected
pkg/workflow/compiler_filters_validation.go(106 lines, 31% comment density - excellent docs)- Missing:
pkg/workflow/compiler_filters_validation_test.go(needs to be created)
Required Test Cases
Create comprehensive table-driven tests covering:
-
Valid configurations:
- ✅ branches only
- ✅ branches-ignore only
- ✅ paths only
- ✅ paths-ignore only
- ✅ no filters
- ✅ multiple events with valid filters
-
Invalid configurations (should error):
- ❌ both branches and branches-ignore
- ❌ both paths and paths-ignore
-
Edge cases:
- Empty filter arrays
- Non-map event values
- Missing 'on' key
Suggested Implementation
func TestValidateEventFilters(t *testing.T) {
tests := []struct {
name string
frontmatter map[string]any
shouldErr bool
}{
{
name: "valid - branches only",
frontmatter: map[string]any{
"on": map[string]any{
"push": map[string]any{
"branches": []string{"main"},
},
},
},
shouldErr: false,
},
{
name: "invalid - both branches and branches-ignore",
frontmatter: map[string]any{
"on": map[string]any{
"push": map[string]any{
"branches": []string{"main"},
"branches-ignore": []string{"dev"},
},
},
},
shouldErr: true,
},
// ... more test cases
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := ValidateEventFilters(tt.frontmatter)
if tt.shouldErr {
assert.Error(t, err, "Should error for mutually exclusive filters")
} else {
assert.NoError(t, err, "Should not error for valid filters")
}
})
}
}Success Criteria
- Test file created:
pkg/workflow/compiler_filters_validation_test.go - All validation logic paths covered with tests
- Tests follow patterns in
specs/testing.md(table-driven, testify assertions) - All tests pass:
make test-unit - Clear test names explain what's being validated
Source
Extracted from Daily Compiler Code Quality Report discussion #10786
Priority
Critical - Validation logic without tests is a significant risk
Estimated Effort
1-2 hours (straightforward table-driven tests)
AI generated by Discussion Task Miner - Code Quality Improvement Agent
- expires on Feb 3, 2026, 2:10 PM UTC
Reactions are currently unavailable