Skip to content

Commit

Permalink
add a further test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexflint committed Jan 24, 2020
1 parent 2cc1f13 commit cb4e079
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,25 @@ func TestEmbeddedPtrIgnored(t *testing.T) {
}

func TestEmbeddedWithDuplicateField(t *testing.T) {
// see https://github.com/alexflint/go-arg/issues/100
type T struct {
A string `arg:"--cat"`
}
type U struct {
A string `arg:"--dog"`
}
var args struct {
T
U
}

err := parse("--cat=cat --dog=dog", &args)
require.NoError(t, err)
assert.Equal(t, "cat", args.T.A)
assert.Equal(t, "dog", args.U.A)
}

func TestEmbeddedWithDuplicateField2(t *testing.T) {
// see https://github.com/alexflint/go-arg/issues/100
type T struct {
A string
Expand All @@ -923,8 +942,10 @@ func TestEmbeddedWithDuplicateField(t *testing.T) {
U
}

err := parse("", &args)
err := parse("--a=xyz", &args)
require.NoError(t, err)
assert.Equal(t, "xyz", args.T.A)
assert.Equal(t, "", args.U.A)
}

func TestEmptyArgs(t *testing.T) {
Expand Down

0 comments on commit cb4e079

Please sign in to comment.