mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
32 lines
772 B
Go
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)
|
|
}
|
|
}
|