Files

31 lines
624 B
Go

package main
import (
"slices"
"testing"
)
// The commands are tested in internal/cli/ws. This test checks newRootCmd
// puts them together.
func TestCommandTree(t *testing.T) {
root := newRootCmd()
var names []string
for _, c := range root.Commands() {
names = append(names, c.Name())
}
for _, want := range []string{"dial", "serve"} {
if !slices.Contains(names, want) {
t.Errorf("ws-test has no %q command; has %v", want, names)
}
}
for _, flag := range []string{"config", "debug", "quiet"} {
if root.PersistentFlags().Lookup(flag) == nil {
t.Errorf("ws-test has no --%s flag", flag)
}
}
}