add nother test
This commit is contained in:
parent
55992853bf
commit
02f3866db2
16
flag_test.go
16
flag_test.go
@ -697,6 +697,22 @@ func TestIntSliceFlagApply_ParentContext(t *testing.T) {
|
|||||||
}).Run([]string{"run", "child"})
|
}).Run([]string{"run", "child"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIntSliceFlag_SetFromParentContext(t *testing.T) {
|
||||||
|
fl := &IntSliceFlag{Name: "numbers", Aliases: []string{"n"}, Value: NewIntSlice(1, 2, 3, 4)}
|
||||||
|
set := flag.NewFlagSet("test", 0)
|
||||||
|
_ = fl.Apply(set)
|
||||||
|
ctx := &Context{
|
||||||
|
parentContext: &Context{
|
||||||
|
flagSet: set,
|
||||||
|
},
|
||||||
|
flagSet: flag.NewFlagSet("empty", 0),
|
||||||
|
}
|
||||||
|
expected := []int{1, 2, 3, 4}
|
||||||
|
if !reflect.DeepEqual(ctx.IntSlice("numbers"), expected) {
|
||||||
|
t.Errorf("child context unable to view parent flag: %v != %v", expected, ctx.IntSlice("numbers"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var int64SliceFlagTests = []struct {
|
var int64SliceFlagTests = []struct {
|
||||||
name string
|
name string
|
||||||
aliases []string
|
aliases []string
|
||||||
|
Loading…
Reference in New Issue
Block a user