-
Notifications
You must be signed in to change notification settings - Fork 19
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
Replace channel with concurrency #154
Conversation
Signed-off-by: David Wertenteil <dwertent@armosec.io>
Signed-off-by: David Wertenteil <dwertent@armosec.io>
PR Analysis
PR Feedback
How to use
|
Summary:
|
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.
Other than the comments I’ve left, LGTM.
Signed-off-by: David Wertenteil <dwertent@armosec.io>
Signed-off-by: David Wertenteil <dwertent@armosec.io>
Signed-off-by: David Wertenteil <dwertent@armosec.io>
Summary:
|
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.
Other than the test, LGTM.
utils/globalvar_test.go
Outdated
if tt.varValue != "" { | ||
os.Setenv(tt.varName, tt.varValue) | ||
} else { | ||
os.Unsetenv(tt.varName) | ||
} |
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.
issue: an environment variable leaks after running this test
Since there is no cleanup of variables after setting them up, an environment variable will leak into the runner system. Which is why it’s a good idea to use test doubles for environment variables, not actual the actual live ones. If we do want the live variables, just use the function provided for testing:
if tt.varValue != "" { | |
os.Setenv(tt.varName, tt.varValue) | |
} else { | |
os.Unsetenv(tt.varName) | |
} | |
if tt.varValue != "" { | |
t.Setenv(tt.varName, tt.varValue) | |
} else { | |
t.Setenv(tt.varName, "") | |
} |
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 implemented it with defer
Signed-off-by: David Wertenteil <dwertent@armosec.io>
Signed-off-by: David Wertenteil <dwertent@armosec.io>
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.
LGTM!
t.Setenv(tt.varName, tt.varValue) | ||
defer t.Setenv(tt.varName, "") |
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.
nitpick(non-blocking): there’s no need to use defer testing.T.Setenv
rolls back your change at the end of test automatically
Signed-off-by: David Wertenteil <dwertent@armosec.io>
Summary:
|
Overview
Replaces channel with concurrency.
Set the desired number with the
WORKER_CONCURRENCY
environment variable.