🎯 Areas for Improvement
1. Missing Tests for isNotFoundError
Location: pkg/parser/remote_fetch.go:609
This is a pure, side-effect-free function with no network dependencies and trivial logic — a perfect unit test candidate that is currently untested.
// isNotFoundError checks if an error message indicates a 404 Not Found response
func isNotFoundError(errMsg string) bool {
lowerMsg := strings.ToLower(errMsg)
return strings.Contains(lowerMsg, "404") || strings.Contains(lowerMsg, "not found")
}
Recommended Test:
func TestIsNotFoundError(t *testing.T) {
tests := []struct {
name string
errMsg string
expected bool
}{
{
name: "message containing 404",
errMsg: "HTTP 404: resource not accessible",
expected: true,
},
{
name: "message containing 'not found' (lowercase)",
errMsg: "not found",
expected: true,
},
{
name: "message containing 'Not Found' (mixed case)",
errMsg: "404 Not Found",
expected: true,
},
{
name: "unrelated error message",
errMsg: "connection refused",
expected: false,
},
{
name: "empty string",
errMsg: "",
expected: false,
},
{
name: "message with 4040 (not a 404)",
errMsg: "error code 4040",
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := isNotFoundError(tt.errMsg)
assert.Equal(t, tt.expected, result, "isNotFoundError(%q)", tt.errMsg)
})
}
}
2. Missing Tests for frontmatterContainsExpressions and containsExpression
Location: pkg/parser/include_processor.go:286-310
These are pure recursive functions used to defer schema validation when import-schema expressions are present. They have no external dependencies and should be unit tested.
func frontmatterContainsExpressions(m map[string]any) bool { ... }
func containsExpression(v any) bool { ... }
Recommended Tests:
func TestFrontmatterContainsExpressions(t *testing.T) {
tests := []struct {
name string
input map[string]any
expected bool
}{
{
name: "empty map",
input: map[string]any{},
expected: false,
},
{
name: "plain string values, no expressions",
input: map[string]any{"engine": "copilot", "version": "1.0"},
expected: false,
},
{
name: "string value with expression",
input: map[string]any{"tools": "$\{\{ github.aw.import-inputs.tools }}"},
expected: true,
},
{
name: "nested map with expression",
input: map[string]any{
"serena": map[string]any{
"path": "$\{\{ github.aw.import-inputs.path }}",
},
},
expected: true,
},
{
name: "slice with expression",
input: map[string]any{
"allowed": []any{"ls", "$\{\{ github.aw.import-inputs.cmd }}"},
},
expected: true,
},
{
name: "nested map with no expressions",
input: map[string]any{
"tools": map[string]any{"bash": map[string]any{"allowed": []any{"ls"}}},
},
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := frontmatterContainsExpressions(tt.input)
assert.Equal(t, tt.expected, result, "frontmatterContainsExpressions(%v)", tt.input)
})
}
}
3. TestIsWorkflowSpec Tests the Unexported Wrapper Instead of the Exported Function
Location: pkg/parser/remote_fetch.go:205-260
The test file calls the unexported isWorkflowSpec (line 255 in source is just return IsWorkflowSpec(path)), but the exported IsWorkflowSpec is the documented API with the full logic. The test should directly test the exported function and its documented contract.
// Current test (tests the thin wrapper)
got := isWorkflowSpec(tt.path)
// Improved (tests the actual exported API)
got := IsWorkflowSpec(tt.path)
This also adds a notable gap: the current test does not cover the "://" URL-like path case which the exported function handles specially:
// From IsWorkflowSpec — currently not tested
if strings.Contains(cleanPath, "://") {
return true // <- this branch is untested!
}
Add this case to the table:
{
name: "URL-like path with :// is treated as workflowspec",
path: "(example.com/redacted),
want: true,
},
4. Duplicated Filesystem Setup Across Three Test Functions
Location: TestResolveIncludePath, TestResolveIncludePath_DotGithubRepo, TestResolveIncludePath_AllPathStyles
Each test independently creates a near-identical directory tree (.github/workflows/, .github/agents/, .agents/) with test files. This setup is roughly 30 lines repeated three times.
Recommended refactor: Extract a shared helper:
type repoLayout struct {
repoRoot string
workflowsDir string
agentsDir string
dotAgentsDir string
workflowFile string
agentFile string
dotAgentFile string
}
func createTestRepoLayout(t *testing.T, tempDir string) repoLayout {
t.Helper()
repoRoot := filepath.Join(tempDir, "repo")
workflowsDir := filepath.Join(repoRoot, ".github", "workflows")
agentsDir := filepath.Join(repoRoot, ".github", "agents")
dotAgentsDir := filepath.Join(repoRoot, ".agents")
for _, dir := range []string{workflowsDir, agentsDir, dotAgentsDir} {
require.NoError(t, os.MkdirAll(dir, 0755), "should create dir %s", dir)
}
workflowFile := filepath.Join(workflowsDir, "workflow.md")
agentFile := filepath.Join(agentsDir, "planner.md")
dotAgentFile := filepath.Join(dotAgentsDir, "agent.md")
for path, content := range map[string]string{
workflowFile: "workflow",
agentFile: "planner",
dotAgentFile: "dot-agent",
} {
require.NoError(t, os.WriteFile(path, []byte(content), 0644), "should write %s", path)
}
return repoLayout{repoRoot, workflowsDir, agentsDir, dotAgentsDir, workflowFile, agentFile, dotAgentFile}
}
Why this matters: Reduces duplication, makes tests easier to maintain, and ensures all tests use consistent fixture data.
5. Incomplete TestProcessImportsFromFrontmatter Coverage
The current test has only 4 cases. Important scenarios not tested:
- Imports with engines — the
wantEngines: true case is never exercised
- Multiple valid imports — only single import tested
- Imports from non-existent file — should return an error
Add these test cases:
{
name: "import file with engines field",
frontmatter: map[string]any{
"on": "push",
"imports": []string{"engine-include.md"}, // a file that specifies engine:
},
wantToolsJSON: false,
wantEngines: true,
wantErr: false,
},
{
name: "import file that does not exist",
frontmatter: map[string]any{
"on": "push",
"imports": []string{"does-not-exist.md"},
},
wantErr: true,
},
The test file
pkg/parser/frontmatter_utils_test.gohas been selected for quality improvement by the Testify Uber Super Expert. This issue provides specific, actionable recommendations to enhance test quality, coverage, and maintainability.Current State
pkg/parser/frontmatter_utils_test.gopkg/parser/remote_fetch.go,pkg/parser/include_processor.goTest Quality Analysis
Strengths ✅
require.*for setup assertions,assert.*for validations, with helpful contextual messages throughout (e.g.,assert.Equal(t, tt.expected, result, "isUnderWorkflowsDirectory(%q)", tt.filePath))t.Run()with descriptive names, including well-documented edge cases (security traversal attacks,.github-repo-named repositories, all path styles)TestResolveIncludePath_AllPathStylescovers path traversal attacks like../../etc/passwdin all prefix variants🎯 Areas for Improvement
1. Missing Tests for
isNotFoundErrorLocation:
pkg/parser/remote_fetch.go:609This is a pure, side-effect-free function with no network dependencies and trivial logic — a perfect unit test candidate that is currently untested.
Recommended Test:
2. Missing Tests for
frontmatterContainsExpressionsandcontainsExpressionLocation:
pkg/parser/include_processor.go:286-310These are pure recursive functions used to defer schema validation when import-schema expressions are present. They have no external dependencies and should be unit tested.
Recommended Tests:
3.
TestIsWorkflowSpecTests the Unexported Wrapper Instead of the Exported FunctionLocation:
pkg/parser/remote_fetch.go:205-260The test file calls the unexported
isWorkflowSpec(line 255 in source is justreturn IsWorkflowSpec(path)), but the exportedIsWorkflowSpecis the documented API with the full logic. The test should directly test the exported function and its documented contract.This also adds a notable gap: the current test does not cover the
"://"URL-like path case which the exported function handles specially:Add this case to the table:
{ name: "URL-like path with :// is treated as workflowspec", path: "(example.com/redacted), want: true, },4. Duplicated Filesystem Setup Across Three Test Functions
Location:
TestResolveIncludePath,TestResolveIncludePath_DotGithubRepo,TestResolveIncludePath_AllPathStylesEach test independently creates a near-identical directory tree (
.github/workflows/,.github/agents/,.agents/) with test files. This setup is roughly 30 lines repeated three times.Recommended refactor: Extract a shared helper:
Why this matters: Reduces duplication, makes tests easier to maintain, and ensures all tests use consistent fixture data.
5. Incomplete
TestProcessImportsFromFrontmatterCoverageThe current test has only 4 cases. Important scenarios not tested:
wantEngines: truecase is never exercisedAdd these test cases:
{ name: "import file with engines field", frontmatter: map[string]any{ "on": "push", "imports": []string{"engine-include.md"}, // a file that specifies engine: }, wantToolsJSON: false, wantEngines: true, wantErr: false, }, { name: "import file that does not exist", frontmatter: map[string]any{ "on": "push", "imports": []string{"does-not-exist.md"}, }, wantErr: true, },📋 Implementation Guidelines
Priority Order
TestIsNotFoundError— pure function, trivially testable, no setup requiredTestIsWorkflowSpecto testIsWorkflowSpec(exported) and add the://branch coverageTestFrontmatterContainsExpressions— pure recursive function, good coverage valueTestProcessImportsFromFrontmatterwith the engines and missing-file casescreateTestRepoLayouthelper to reduce duplicationBest Practices from
scratchpad/testing.mdrequire.*for critical setup (stops test on failure)assert.*for test validations (continues checking)t.Run()and descriptive namesTesting Commands
Acceptance Criteria
TestIsNotFoundErroradded with at least 5 table-driven cases (truthy 404 strings, falsy strings, edge cases)TestFrontmatterContainsExpressionsadded covering: empty map, flat expressions, nested map, slice, no expressionsTestIsWorkflowSpecupdated to call exportedIsWorkflowSpecand covers the://branchTestProcessImportsFromFrontmatterexpanded with engines case and missing-file error casecreateTestRepoLayouthelper extracted to reduce filesystem setup duplicationgo test ./pkg/parser/scratchpad/testing.mdAdditional Context
scratchpad/testing.mdfor comprehensive testing patternsisNotFoundError:pkg/parser/remote_fetch.go:609frontmatterContainsExpressions:pkg/parser/include_processor.go:286Priority: Medium
Effort: Small (most improvements are adding new table cases or small test functions)
Expected Impact: Improved coverage of pure utility functions, catches regressions in
isNotFoundErrorlogic, ensures exported APIIsWorkflowSpecis contract-testedFiles Involved:
pkg/parser/frontmatter_utils_test.gopkg/parser/remote_fetch.go,pkg/parser/include_processor.goReferences: