Objective
Add comprehensive test coverage for shell completion functions in pkg/cli/completions.go to ensure they return correct suggestions and handle edge cases.
Context
The completion system is well-implemented but lacks explicit test coverage. Tests ensure completions continue working correctly as the codebase evolves.
Implementation Approach
-
Create or update test file pkg/cli/completions_test.go
-
Test completion functions:
func TestCompleteWorkflowNames(t *testing.T) {
tests := []struct {
name string
setupWorkflows []string
toComplete string
expectContains []string
}{
{
name: "all workflows when empty prefix",
setupWorkflows: []string{"deploy", "test", "ci"},
toComplete: "",
expectContains: []string{"deploy", "test", "ci"},
},
{
name: "filtered workflows with prefix",
setupWorkflows: []string{"deploy-prod", "deploy-dev", "test"},
toComplete: "dep",
expectContains: []string{"deploy-prod", "deploy-dev"},
},
}
// Implementation
}
-
Test edge cases:
- Empty workflow directory
- Invalid workflow files
- Missing .md extension
- Special characters in workflow names
-
Test other completion functions:
CompleteEngineNames() - Test engine suggestions
CompleteDirectories() - Test directory completion
- MCP server name completion (if testable)
-
Use table-driven tests following gh-aw testing conventions
Files to Create/Modify
Acceptance Criteria
References
AI generated by Plan Command for discussion #8545
Objective
Add comprehensive test coverage for shell completion functions in
pkg/cli/completions.goto ensure they return correct suggestions and handle edge cases.Context
The completion system is well-implemented but lacks explicit test coverage. Tests ensure completions continue working correctly as the codebase evolves.
Implementation Approach
Create or update test file
pkg/cli/completions_test.goTest completion functions:
Test edge cases:
Test other completion functions:
CompleteEngineNames()- Test engine suggestionsCompleteDirectories()- Test directory completionUse table-driven tests following gh-aw testing conventions
Files to Create/Modify
Create/Update:
pkg/cli/completions_test.goTestCompleteWorkflowNames()TestCompleteEngineNames()TestCompleteDirectories()Reference:
pkg/cli/completions.goAcceptance Criteria
CompleteWorkflowNames()includes prefix filteringCompleteEngineNames()validates engine listCompleteDirectories()validates path handlingmake test-unitReferences
specs/testing.mdpkg/cli/*_test.goRelated to [plan] Enhance Cobra CLI implementation with completion descriptions and context support #8552