spf13--cobra/cobra/cmd/add_test.go
Albert Nigmatzianov 6bcf163261 cmd: Validate cmd names
Fix #269
2017-05-05 10:35:27 +02:00

25 lines
528 B
Go

package cmd
import "testing"
func TestValidateCmdName(t *testing.T) {
testCases := []struct {
input string
expected string
}{
{"cmdName", "cmdName"},
{"cmd_name", "cmdName"},
{"cmd-name", "cmdName"},
{"cmd______Name", "cmdName"},
{"cmd------Name", "cmdName"},
{"cmd______name", "cmdName"},
{"cmd------name", "cmdName"},
}
for _, testCase := range testCases {
got := validateCmdName(testCase.input)
if testCase.expected != got {
t.Errorf("Expected %q, got %q", testCase.expected, got)
}
}
}