Skip to content

Commit

Permalink
add nother test
Browse files Browse the repository at this point in the history
  • Loading branch information
anicoll committed Dec 9, 2020
1 parent 5599285 commit 02f3866
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions flag_test.go
Expand Up @@ -697,6 +697,22 @@ func TestIntSliceFlagApply_ParentContext(t *testing.T) {
}).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 {
name string
aliases []string
Expand Down

0 comments on commit 02f3866

Please sign in to comment.