add test for case where environment var is not present

This commit is contained in:
Alex Flint 2019-05-02 09:44:48 -07:00
parent f2f7bdbbd7
commit c8c61cf8bb
1 changed files with 9 additions and 0 deletions

View File

@ -557,6 +557,15 @@ func TestEnvironmentVariable(t *testing.T) {
assert.Equal(t, "bar", args.Foo)
}
func TestEnvironmentVariableNotPresent(t *testing.T) {
var args struct {
NotPresent string `arg:"env"`
}
os.Args = []string{"example"}
MustParse(&args)
assert.Equal(t, "", args.NotPresent)
}
func TestEnvironmentVariableOverrideName(t *testing.T) {
var args struct {
Foo string `arg:"env:BAZ"`