cmd/mcp_test: use t.Setenv to prevent env var leak across tests#3688
cmd/mcp_test: use t.Setenv to prevent env var leak across tests#3688Elvand-Lie wants to merge 1 commit intoknative:mainfrom
Conversation
TestMCP_StartWriteable sets FUNC_ENABLE_MCP_WRITE via os.Setenv but never cleans it up. Since Go runs all tests in a package within the same process, this leaked env var persists for subsequent tests. Replace os.Setenv with t.Setenv, which automatically restores the original value when the test finishes. Remove the now-unused os import. Fixes knative#3686 Signed-off-by: elvandlie@gmail.com <elvandlie@gmail.com>
|
@Elvand-Lie: The label(s) DetailsIn 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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Elvand-Lie The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
|
|
Welcome @Elvand-Lie! It looks like this is your first PR to knative/func 🎉 |
|
Hi @Elvand-Lie. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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-sigs/prow repository. |
|
/kind bug |
|
@Elvand-Lie: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn 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-sigs/prow repository. |
TestMCP_StartWriteable sets FUNC_ENABLE_MCP_WRITE via os.Setenv but never cleans it up. Since Go runs all tests in a package within the same process, this leaked env var persists for subsequent tests.
Replace os.Setenv with t.Setenv, which automatically restores the original value when the test finishes. Remove the now-unused os import.
Changes
os.Setenvwitht.SetenvinTestMCP_StartWriteableto auto-restore the env var after the test"os"import fromcmd/mcp_test.goFixes #3686
Release Note