Commit b31facdf authored by Christian Couder's avatar Christian Couder

parse_test: move helper functions

License: MIT
Signed-off-by: default avatarChristian Couder <chriscool@tuxfamily.org>
parent 15e3579a
......@@ -7,31 +7,19 @@ import (
"github.com/ipfs/go-ipfs/commands"
)
func TestOptionParsing(t *testing.T) {
subCmd := &commands.Command{}
cmd := &commands.Command{
Options: []commands.Option{
commands.StringOption("string", "s", "a string"),
commands.BoolOption("bool", "b", "a bool"),
},
Subcommands: map[string]*commands.Command{
"test": subCmd,
},
}
type kvs map[string]interface{}
type words []string
type kvs map[string]interface{}
type words []string
sameWords := func(a words, b words) bool {
func sameWords(a words, b words) bool {
for i, w := range a {
if w != b[i] {
return false
}
}
return true
}
}
sameKVs := func(a kvs, b kvs) bool {
func sameKVs(a kvs, b kvs) bool {
if len(a) != len(b) {
return false
}
......@@ -41,6 +29,18 @@ func TestOptionParsing(t *testing.T) {
}
}
return true
}
func TestOptionParsing(t *testing.T) {
subCmd := &commands.Command{}
cmd := &commands.Command{
Options: []commands.Option{
commands.StringOption("string", "s", "a string"),
commands.BoolOption("bool", "b", "a bool"),
},
Subcommands: map[string]*commands.Command{
"test": subCmd,
},
}
testHelper := func(args string, expectedOpts kvs, expectedWords words, expectErr bool) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment