-
Notifications
You must be signed in to change notification settings - Fork 244
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
test: use T.Setenv
to set env vars in tests
#6037
test: use T.Setenv
to set env vars in tests
#6037
Conversation
This commit replaces `os.Setenv` with `t.Setenv` in tests. The environment variable is automatically restored to its original value when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.Setenv Signed-off-by: Eng Zer Jun <[email protected]>
@Juneezee: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
✅ Deploy Preview for odo-docusaurus-preview canceled.
|
Hi @Juneezee. Thanks for your PR. I'm waiting for a redhat-developer member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
/ok-to-test |
Thanks @Juneezee for these changes /lgtm /override windows-integration-test/Windows-test |
@feloy: Overrode contexts on behalf of feloy: windows-integration-test/Windows-test In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: feloy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/override ci/prow/v4.10-integration-e2e |
@valaparthvi: Overrode contexts on behalf of valaparthvi: ci/prow/v4.10-integration-e2e In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This commit replaces `os.Setenv` with `t.Setenv` in tests. The environment variable is automatically restored to its original value when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.Setenv Signed-off-by: Eng Zer Jun <[email protected]> Signed-off-by: Eng Zer Jun <[email protected]>
What type of PR is this:
/kind cleanup
What does this PR do / why we need it:
This PR replaces
os.Setenv
witht.Setenv
. Starting from Go 1.17, we can uset.Setenv
to set environment variable in test. The environment variable is automatically restored to its original value when the test and all its subtests complete. This ensures that each test does not start with leftover environment variables from previous completed tests.This saves us at least 2 lines (error check, and unsetting the env var) on every instance.
Reference: https://pkg.go.dev/testing#T.Setenv
Which issue(s) this PR fixes:
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer: