Skip to content

Add comprehensive test coverage for CLI completion functions#8566

Merged
pelikhan merged 2 commits intomainfrom
copilot/add-test-coverage-cli-completion
Jan 2, 2026
Merged

Add comprehensive test coverage for CLI completion functions#8566
pelikhan merged 2 commits intomainfrom
copilot/add-test-coverage-cli-completion

Conversation

Copy link
Contributor

Copilot AI commented Jan 2, 2026

The completion system in pkg/cli/completions.go lacked explicit test coverage for edge cases and special scenarios that could break shell completion behavior.

Changes

Added 8 test functions covering edge cases:

  • Special characters in workflow names (dashes, underscores, dots, mixed)
  • Invalid/empty .md files and non-.md files in workflow directories
  • Case-sensitive prefix matching behavior
  • Exact match scenarios
  • Long workflow names (200+ characters)
  • Engine name consistency across multiple calls
  • Case sensitivity in engine name completion

Test structure follows repository conventions:

  • Table-driven tests with descriptive subtests
  • require.* for setup, assert.* for validations
  • 26 subtests across 15 total test functions

Example

func TestCompleteWorkflowNamesWithSpecialCharacters(t *testing.T) {
    tests := []struct {
        name           string
        toComplete     string
        expectedCount  int
        expectContains []string
    }{
        {
            name:           "workflows with test- prefix",
            toComplete:     "test-",
            expectedCount:  2,
            expectContains: []string{"test-workflow", "test-123"},
        },
        // ...
    }
    // ...
}

Ensures shell completions continue working correctly as the codebase evolves.

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Add test coverage for CLI completion functions</issue_title>
<issue_description>## 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

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Add tests for special characters in workflow names (dashes, underscores, dots)
- Add tests for invalid/empty .md files and non-.md files in workflows directory
- Add tests for case-sensitive prefix matching
- Add tests for exact matches in completions
- Add tests for long workflow names (200+ characters)
- Add tests for engine name exact matches and case sensitivity
- Add tests for ValidEngineNames consistency across multiple calls
- All tests use table-driven patterns following gh-aw conventions
- Tests use require for setup and assert for validations

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test coverage for CLI completion functions Add comprehensive test coverage for CLI completion functions Jan 2, 2026
Copilot AI requested a review from mnkiefer January 2, 2026 05:13
@pelikhan pelikhan marked this pull request as ready for review January 2, 2026 05:13
@pelikhan pelikhan merged commit 5a70475 into main Jan 2, 2026
168 of 169 checks passed
@pelikhan pelikhan deleted the copilot/add-test-coverage-cli-completion branch January 2, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Add test coverage for CLI completion functions

3 participants