chore: import upstream snapshot with attribution
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
// TestHelpCommandGroups asserts `gortex --help` is organized into intent
|
||||
// groups (not a flat command list): the groups are registered, key
|
||||
// commands carry the right group, and no command references an
|
||||
// unregistered group (which cobra would panic on at help time).
|
||||
func TestHelpCommandGroups(t *testing.T) {
|
||||
assignCommandGroups()
|
||||
|
||||
registered := map[string]bool{}
|
||||
for _, g := range rootCmd.Groups() {
|
||||
registered[g.ID] = true
|
||||
}
|
||||
for _, id := range []string{"serve", "engine", "query", "edit", "memory", "index", "setup"} {
|
||||
if !registered[id] {
|
||||
t.Errorf("intent group %q is not registered", id)
|
||||
}
|
||||
}
|
||||
|
||||
// Representative commands land in the expected group.
|
||||
want := map[string]string{
|
||||
"mcp": "serve", "daemon": "engine", "track": "engine",
|
||||
"query": "query", "audit": "query", "edit": "edit", "memory": "memory", "enrich": "index", "config": "setup",
|
||||
}
|
||||
got := map[string]string{}
|
||||
for _, c := range rootCmd.Commands() {
|
||||
got[c.Name()] = c.GroupID
|
||||
}
|
||||
for name, wantID := range want {
|
||||
if got[name] != wantID {
|
||||
t.Errorf("command %q group = %q, want %q", name, got[name], wantID)
|
||||
}
|
||||
}
|
||||
|
||||
// Every assigned GroupID must reference a registered group.
|
||||
for _, c := range rootCmd.Commands() {
|
||||
if c.GroupID != "" && !registered[c.GroupID] {
|
||||
t.Errorf("command %q has unregistered group %q", c.Name(), c.GroupID)
|
||||
}
|
||||
}
|
||||
|
||||
// Idempotent: a second call must not duplicate groups.
|
||||
before := len(rootCmd.Groups())
|
||||
assignCommandGroups()
|
||||
if after := len(rootCmd.Groups()); after != before {
|
||||
t.Errorf("assignCommandGroups not idempotent: groups %d -> %d", before, after)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user