提交 2a5b2f2f 作者: Christian Couder

parse_test: move helper functions

License: MIT
Signed-off-by: 's avatarChristian Couder <chriscool@tuxfamily.org>
上级 cc5f6bb3
...@@ -7,31 +7,19 @@ import ( ...@@ -7,31 +7,19 @@ import (
"github.com/ipfs/go-ipfs/commands" "github.com/ipfs/go-ipfs/commands"
) )
func TestOptionParsing(t *testing.T) { type kvs map[string]interface{}
subCmd := &commands.Command{} type words []string
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
sameWords := func(a words, b words) bool { func sameWords(a words, b words) bool {
for i, w := range a { for i, w := range a {
if w != b[i] { if w != b[i] {
return false return false
} }
} }
return true return true
} }
sameKVs := func(a kvs, b kvs) bool { func sameKVs(a kvs, b kvs) bool {
if len(a) != len(b) { if len(a) != len(b) {
return false return false
} }
...@@ -41,6 +29,18 @@ func TestOptionParsing(t *testing.T) { ...@@ -41,6 +29,18 @@ func TestOptionParsing(t *testing.T) {
} }
} }
return true 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) { testHelper := func(args string, expectedOpts kvs, expectedWords words, expectErr bool) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论