mirror of
https://github.com/spf13/cobra
synced 2024-11-05 05:17:12 +00:00
26 lines
528 B
Go
26 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)
|
||
|
}
|
||
|
}
|
||
|
}
|