parse_test: move helper functions
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
May 2, 2015 at 22:35 UTC
2a5b2f2f4a21c77d9b7f518d0607875d8af220c8
1 file changed
+24
-24
commands/cli/parse_test.go
+24
-24
@@ -7,6 +7,30 @@ import (
7
"github.com/ipfs/go-ipfs/commands"
8
)
9
10
+type kvs map[string]interface{}
11
+type words []string
12
+
13
+func sameWords(a words, b words) bool {
14
+ for i, w := range a {
15
+ if w != b[i] {
16
+ return false
17
+ }
18
+ }
19
+ return true
20
+}
21
+
22
+func sameKVs(a kvs, b kvs) bool {
23
+ if len(a) != len(b) {
24
+ return false
25
+ }
26
+ for k, v := range a {
27
+ if v != b[k] {
28
+ return false
29
+ }
30
+ }
31
+ return true
32
+}
33
+
34
func TestOptionParsing(t *testing.T) {
35
subCmd := &commands.Command{}
36
cmd := &commands.Command{
@@ -19,30 +43,6 @@ func TestOptionParsing(t *testing.T) {
43
},
44
}
45
22
- type kvs map[string]interface{}
23
- type words []string
24
-
25
- sameWords := func(a words, b words) bool {
26
- for i, w := range a {
27
- if w != b[i] {
28
- return false
29
- }
30
- }
31
- return true
32
- }
33
-
34
- sameKVs := func(a kvs, b kvs) bool {
35
- if len(a) != len(b) {
36
- return false
37
- }
38
- for k, v := range a {
39
- if v != b[k] {
40
- return false
41
- }
42
- }
43
- return true
44
- }
45
-
46
testHelper := func(args string, expectedOpts kvs, expectedWords words, expectErr bool) {
47
_, opts, input, _, err := parseOpts(strings.Split(args, " "), cmd)
48
if expectErr {