diff options
| author | Sebastiaan Pasterkamp <[email protected]> | 2022-01-02 15:06:37 +0100 |
|---|---|---|
| committer | Sebastiaan Pasterkamp <[email protected]> | 2022-01-02 15:17:09 +0100 |
| commit | a87d80089a78b707d9e4fbd7061e54e7e834688d (patch) | |
| tree | d0cf8e9ccc77b6ef99a1684117c1f233f781c823 /parse_test.go | |
| parent | bf32f082479c88da7bcf4c4765a70e3a357d9dfc (diff) | |
Add 'IgnoreDefault' option
Diffstat (limited to 'parse_test.go')
| -rw-r--r-- | parse_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/parse_test.go b/parse_test.go index 2d0ef7a..aebe5ff 100644 --- a/parse_test.go +++ b/parse_test.go @@ -816,6 +816,19 @@ func TestEnvironmentVariableIgnored(t *testing.T) { assert.Equal(t, "", args.Foo) } +func TestDefaultValuesIgnored(t *testing.T) { + var args struct { + Foo string `default:"bad"` + } + + p, err := NewParser(Config{IgnoreDefault: true}, &args) + require.NoError(t, err) + + err = p.Parse(nil) + assert.NoError(t, err) + assert.Equal(t, "", args.Foo) +} + func TestEnvironmentVariableInSubcommandIgnored(t *testing.T) { var args struct { Sub *struct { |
