diff options
| author | Alex Flint <[email protected]> | 2020-01-24 14:42:49 -0800 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2020-01-24 14:42:49 -0800 |
| commit | cb4e079d13af069a75c6549216c6902a7569f57f (patch) | |
| tree | f8f784af05d2c822e1092fc6d423318c5743bac9 | |
| parent | 2cc1f136b1375d20aff0ca5429d69af4b0597939 (diff) | |
add a further test
| -rw-r--r-- | parse_test.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/parse_test.go b/parse_test.go index ff521ae..5cae598 100644 --- a/parse_test.go +++ b/parse_test.go @@ -913,6 +913,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 } type U struct { @@ -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) { |
