-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix int parsing for arg:"env" when environment variable value is empty #169
Fix int parsing for arg:"env" when environment variable value is empty #169
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR, but I think there is some non-trivial subtlety to work out as per comments regarding *string
values, err = csv.NewReader(strings.NewReader(value)).Read() | ||
value = strings.TrimSpace(value) | ||
|
||
if len(value) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will break the case that an argument type is *string
and the env var is present but is empty, in which case the argument should be initialized to a non-null string, but its contents should be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I missed this situation right now the argument is initialized null when this happens. I will work on this fix
@@ -677,6 +677,42 @@ func TestEnvironmentVariable(t *testing.T) { | |||
assert.Equal(t, "bar", args.Foo) | |||
} | |||
|
|||
func TestEnvironmentVariableInt(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you add 3 extra test cases:
- argument type is
*string
and environment variable is absent - argument type is
*string
and environment variable is present and empty - argument type is
*string
and environment variable is present and non-empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add these test cases
when, argument type is *string and environment variable is absent argument type is *string and environment variable is present and empty argument type is *string and environment variable is present and non-empty
This PR fixes a bug in reference to #160