Skip to content

Add test ensuring all CLI commands are registered#137

Closed
joelklabo wants to merge 1 commit intoagentregistry-dev:mainfrom
joelklabo:test/cli-command-registration
Closed

Add test ensuring all CLI commands are registered#137
joelklabo wants to merge 1 commit intoagentregistry-dev:mainfrom
joelklabo:test/cli-command-registration

Conversation

@joelklabo
Copy link
Copy Markdown
Contributor

Summary

Addresses #77. Adds TestAllCommandsRegistered in pkg/cli/root_test.go which verifies that every expected top-level command and subcommand is present in the cobra command tree.

  • Checks all 8 top-level commands (agent, configure, embeddings, export, import, mcp, skill, version)
  • Checks subcommands for agent (12), mcp (11), skill (8), and embeddings (1)
  • If a new command is added to the source but not to the expected list (or vice versa), the test fails with a clear diff

Test plan

  • go test ./pkg/cli/ -run TestAllCommandsRegistered -v passes
  • All existing tests still pass (go test ./pkg/cli/... ./internal/cli/...)
  • go vet ./pkg/cli/ clean

Addresses agentregistry-dev#77. Adds TestAllCommandsRegistered which verifies that every
expected top-level command and subcommand is present in the cobra command
tree. This catches cases where a new command is added to the source but
not registered (or vice versa).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@joelklabo joelklabo marked this pull request as ready for review February 9, 2026 17:21
@joelklabo
Copy link
Copy Markdown
Contributor Author

The lint is failing because the code uses the sort package but the project requires using slices instead (per the forbid-pkg-errors depguard rule).\n\nFix needed: Replace:\n- import "sort"import "slices"\n- sort.Strings(names)slices.Sort(names)\n- sort.Strings(sortedExpected)slices.Sort(sortedExpected)\n- sort.Strings(sortedGot)slices.Sort(sortedGot)\n\nWould you like me to push this fix to the branch?

peterj pushed a commit that referenced this pull request Feb 25, 2026
# Description

Add complementary unit tests for CLI command tree structure, flag
registration, required flag validation, hidden command detection,
and argument count validators.

Test coverage includes:
- `TestCommandTree` - verifies all 8 top-level commands and subcommand
counts
- `TestCommandsHaveRequiredMetadata` - walks entire tree checking
Use/Short fields
- `TestHiddenCommands` - verifies import/export are hidden
- `TestAgentInitFlags` - 6 flags with correct defaults
- `TestSkillPublishFlags` - 5 flags with defaults + required flag check
- `TestRequiredFlags` - 4 commands with required flags validated
- `TestRootPersistentFlags` - registry-url and registry-token
- `TestArgsValidators` - 16 cases testing ExactArgs/ArbitraryArgs
enforcement

Uses `slices.Sort` instead of forbidden `sort` package.

Fixes #77

# Change Type

/kind feature

# Changelog

```release-note
Add CLI command registration and flag unit tests
```

# Additional Notes

- Complementary to PR #137 (stalled on lint failure from `sort` package
usage)
- Uses `slices.Sort` to comply with `depguard` linter rule
- Single new file: `pkg/cli/commands_test.go` (346 lines, 39+ subtests)
@github-actions
Copy link
Copy Markdown

This pull request has been marked as stale due to no activity in the last 14 days. It will be closed in 3 days unless it is tagged "no stalebot" or other activity occurs.

@github-actions github-actions bot added the stale label Feb 28, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

This pull request has been closed due to inactivity.

@github-actions github-actions bot closed this Mar 3, 2026
christian-posta pushed a commit to christian-posta/agentregistry that referenced this pull request Mar 9, 2026
…-dev#207)

# Description

Add complementary unit tests for CLI command tree structure, flag
registration, required flag validation, hidden command detection,
and argument count validators.

Test coverage includes:
- `TestCommandTree` - verifies all 8 top-level commands and subcommand
counts
- `TestCommandsHaveRequiredMetadata` - walks entire tree checking
Use/Short fields
- `TestHiddenCommands` - verifies import/export are hidden
- `TestAgentInitFlags` - 6 flags with correct defaults
- `TestSkillPublishFlags` - 5 flags with defaults + required flag check
- `TestRequiredFlags` - 4 commands with required flags validated
- `TestRootPersistentFlags` - registry-url and registry-token
- `TestArgsValidators` - 16 cases testing ExactArgs/ArbitraryArgs
enforcement

Uses `slices.Sort` instead of forbidden `sort` package.

Fixes agentregistry-dev#77

# Change Type

/kind feature

# Changelog

```release-note
Add CLI command registration and flag unit tests
```

# Additional Notes

- Complementary to PR agentregistry-dev#137 (stalled on lint failure from `sort` package
usage)
- Uses `slices.Sort` to comply with `depguard` linter rule
- Single new file: `pkg/cli/commands_test.go` (346 lines, 39+ subtests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant