Skip to content

Commit

Permalink
Update based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skelouse committed Oct 7, 2023
1 parent 72f7639 commit 594ab74
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 1 addition & 3 deletions altsrc/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ func (f *StringSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSour
}

Check warning on line 116 in altsrc/flag.go

View check run for this annotation

Codecov / codecov/patch

altsrc/flag.go#L115-L116

Added lines #L115 - L116 were not covered by tests
}
if f.Destination != nil {
if err := f.Destination.Set(sliceValue.Serialize()); err != nil {
return err
}
_ = f.Destination.Set(sliceValue.Serialize())
}
}
return nil
Expand Down
18 changes: 18 additions & 0 deletions altsrc/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ func TestGenericApplyInputSourceValue(t *testing.T) {
refute(t, v, c.Generic("test"))
}

func TestGenericApplyInputSourceValueError(t *testing.T) {
set := flag.NewFlagSet("", flag.ContinueOnError)
c := cli.NewContext(nil, set, nil)

testFlag := &GenericFlag{
GenericFlag: &cli.GenericFlag{
Name: "test",
Value: &cli.StringSlice{},
},
set: set,
}

err := testFlag.ApplyInputSourceValue(c, NewMapInputSource("", map[interface{}]interface{}{
"test": testFlag.Value,
}))
expect(t, err, fmt.Errorf("no such flag -test"))
}

func TestGenericApplyInputSourceMethodContextSet(t *testing.T) {
p := &Parser{"abc", "def"}
tis := testApplyInputSource{
Expand Down

0 comments on commit 594ab74

Please sign in to comment.