commands/cli: Added test for single-dash option value
Matt Bell committed
Oct 14, 2014 at 15:16 UTC
5d9fa93c85b82b5a91b7d4bb77c7bc8001102da7
1 file changed
+7
-3
commands/cli/parse_test.go
+7
-3
@@ -8,10 +8,14 @@ import (
8
)
9
10
func TestOptionParsing(t *testing.T) {
11
- cmd := &commands.Command{}
11
+ cmd := &commands.Command{
12
+ Options: []commands.Option{
13
+ commands.Option{ []string{"b"}, commands.String },
14
+ },
15
+ }
16
cmd.Register("test", &commands.Command{})
17
14
- opts, input, err := parseOptions([]string{ "--beep", "--boop=\"5", "lol\"", "test2", "-cV" },
18
+ opts, input, err := parseOptions([]string{ "--beep", "--boop=\"5", "lol\"", "test2", "-cVb", "beep" },
19
[]string{"test"}, cmd)
20
/*for k, v := range opts {
21
fmt.Printf("%s: %s\n", k, v)
@@ -20,7 +24,7 @@ func TestOptionParsing(t *testing.T) {
24
if err != nil {
25
t.Error("Should have passed")
26
}
23
- if len(opts) != 4 || opts["c"] != "" || opts["V"] != "" || opts["beep"] != "" || opts["boop"] != "5 lol" {
27
+ if len(opts) != 5 || opts["c"] != "" || opts["V"] != "" || opts["beep"] != "" || opts["boop"] != "5 lol" || opts["b"] != "beep" {
28
t.Error("Returned options were defferent than expected: %v", opts)
29
}
30
if len(input) != 1 || input[0] != "test2" {