Skip to content

[plan] Add test coverage for CLI completion functions #8555

Description

@github-actions

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

  1. Create or update test file pkg/cli/completions_test.go

  2. 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
    }
  3. Test edge cases:

    • Empty workflow directory
    • Invalid workflow files
    • Missing .md extension
    • Special characters in workflow names
  4. Test other completion functions:

    • CompleteEngineNames() - Test engine suggestions
    • CompleteDirectories() - Test directory completion
    • MCP server name completion (if testable)
  5. Use table-driven tests following gh-aw testing conventions

Files to Create/Modify

  • Create/Update: pkg/cli/completions_test.go

    • Add TestCompleteWorkflowNames()
    • Add TestCompleteEngineNames()
    • Add TestCompleteDirectories()
    • Add helper functions for test setup
  • Reference: pkg/cli/completions.go

    • Ensure completion functions are testable (accept test directories)

Acceptance Criteria

  • Test coverage for CompleteWorkflowNames() includes prefix filtering
  • Test coverage for CompleteEngineNames() validates engine list
  • Test coverage for CompleteDirectories() validates path handling
  • Edge cases tested (empty dir, invalid files, special chars)
  • Tests follow table-driven pattern per gh-aw conventions
  • Tests pass with make test-unit

References

AI generated by Plan Command for discussion #8545

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions