package cli import ( "strings" "testing" ) func TestCertCommandRegistered(t *testing.T) { found := false for _, cmd := range rootCmd.Commands() { if strings.Fields(cmd.Use)[0] == "cert" { found = true break } } if !found { t.Fatal("cert command not registered on rootCmd") } } func TestCertSubcommands(t *testing.T) { expected := []string{"ca-init", "gen", "show", "renew", "fingerprint"} registered := make(map[string]bool) for _, cmd := range rootCmd.Commands() { if strings.Fields(cmd.Use)[0] != "cert" { continue } for _, sub := range cmd.Commands() { registered[strings.Fields(sub.Use)[0]] = true } } for _, name := range expected { if !registered[name] { t.Errorf("expected cert subcommand %q not registered", name) } } }