commands/cli: Added simple option parser test
Matt Bell committed
Oct 13, 2014 at 19:18 UTC
b3eecf4f64aca4be377d1a1ded0c48670308d28c
1 file changed
+23
commands/cli/parse_test.go
new
+23
@@ -0,0 +1,23 @@
1
+package cli
2
+
3
+import (
4
+ //"fmt"
5
+ "testing"
6
+)
7
+
8
+func TestOptionParsing(t *testing.T) {
9
+ opts, input, err := options([]string{ "test", "--beep", "--boop=\"5", "lol\"", "test2", "-cV" }, nil)
10
+ /*for k, v := range opts {
11
+ fmt.Printf("%s: %s\n", k, v)
12
+ }
13
+ fmt.Printf("%s\n", input)*/
14
+ if err != nil {
15
+ t.Error("Should have passed")
16
+ }
17
+ if len(opts) != 4 || opts["c"] != "" || opts["V"] != "" || opts["beep"] != "" || opts["boop"] != "5 lol" {
18
+ t.Error("Returned options were defferent than expected: %v", opts)
19
+ }
20
+ if len(input) != 2 || input[0] != "test" || input[1] != "test2" {
21
+ t.Error("Returned input was different than expected: %v", input)
22
+ }
23
+}