Files
Devour/cmd/root_test.go
T
Tomas Dvorak 898a3c303f update
2026-02-24 10:33:59 +01:00

32 lines
772 B
Go

package cmd
import "testing"
func TestRootCommandsAreUnique(t *testing.T) {
seen := map[string]bool{}
for _, c := range rootCmd.Commands() {
name := c.Name()
if seen[name] {
t.Fatalf("duplicate root command registered: %s", name)
}
seen[name] = true
}
}
func TestQueryLimitShorthandIsN(t *testing.T) {
flag := queryCmd.Flags().Lookup("limit")
if flag == nil {
t.Fatal("query --limit flag not found")
}
if flag.Shorthand != "n" {
t.Fatalf("expected query --limit shorthand to be n, got %q", flag.Shorthand)
}
}
func TestRootExecuteQueryNoPanic(t *testing.T) {
rootCmd.SetArgs([]string{"query", "http client", "--limit", "1"})
if _, err := rootCmd.ExecuteC(); err != nil {
t.Fatalf("query execution should not panic; got error: %v", err)
}
}