fix(context): copy StringSlice Flag correctly

This commit is contained in:
Yicheng Qin
2014-03-18 19:26:57 -07:00
parent 4097aa09fe
commit ce13660ae0
2 changed files with 29 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package cli_test
import (
"github.com/codegangsta/cli"
"reflect"
"testing"
)
@@ -101,6 +102,22 @@ func TestParseMultiString(t *testing.T) {
}).Run([]string{"run", "-s", "10"})
}
func TestParseMultiStringSlice(t *testing.T) {
(&cli.App{
Flags: []cli.Flag{
cli.StringSliceFlag{Name: "serve, s", Value: &cli.StringSlice{}},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.StringSlice("serve"), []string{"10", "20"}) {
t.Errorf("main name not set")
}
if !reflect.DeepEqual(ctx.StringSlice("s"), []string{"10", "20"}) {
t.Errorf("short name not set")
}
},
}).Run([]string{"run", "-s", "10", "-s", "20"})
}
func TestParseMultiInt(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{