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)
}
// func TestEnvironmentVariableIgnored(t *testing.T) {
// var args struct {
// Foo string `arg:"env"`
// }
// setenv(t, "FOO", "abc")
func TestEnvironmentVariableIgnored(t *testing.T) {
var args struct {
Foo string `arg:"env"`
}
// p, err := NewParser(Config{IgnoreEnv: true}, &args)
// require.NoError(t, err)
// the library should never read env vars direct from os
os.Setenv("FOO", "123")
// err = p.Parse(nil)
// assert.NoError(t, err)
// assert.Equal(t, "", args.Foo)
// }
_, err := parseWithEnv(&args, "")
require.NoError(t, err)
assert.Equal(t, "", args.Foo)
}
// func TestDefaultValuesIgnored(t *testing.T) {
// var args struct {