added test that library does not directly access environment variables from OS

This commit is contained in:
Alex Flint 2022-10-04 11:02:46 -07:00
parent 09d28e1195
commit 22f214d7ed
1 changed files with 10 additions and 11 deletions

View File

@ -792,19 +792,18 @@ func TestEnvironmentVariableEmptyMap(t *testing.T) {
assert.Len(t, args.Foo, 0) assert.Len(t, args.Foo, 0)
} }
// func TestEnvironmentVariableIgnored(t *testing.T) { func TestEnvironmentVariableIgnored(t *testing.T) {
// var args struct { var args struct {
// Foo string `arg:"env"` Foo string `arg:"env"`
// } }
// setenv(t, "FOO", "abc")
// p, err := NewParser(Config{IgnoreEnv: true}, &args) // the library should never read env vars direct from os
// require.NoError(t, err) os.Setenv("FOO", "123")
// err = p.Parse(nil) _, err := parseWithEnv(&args, "")
// assert.NoError(t, err) require.NoError(t, err)
// assert.Equal(t, "", args.Foo) assert.Equal(t, "", args.Foo)
// } }
// func TestDefaultValuesIgnored(t *testing.T) { // func TestDefaultValuesIgnored(t *testing.T) {
// var args struct { // var args struct {