-
Notifications
You must be signed in to change notification settings - Fork 545
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: handle process.env in config_test.ts #2294
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.
PR Overview
This PR addresses issues with tests failing due to unexpected environment variables by isolating environment values during test execution. Key changes include storing the original environment variables, replacing process.env with an empty object for testing, and restoring process.env after tests complete.
Reviewed Changes
File | Description |
---|---|
src/config_test.ts | Updated test hooks to shield tests from external process.env values |
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
before(() => { | ||
// The code being tested here references process.env and can fail | ||
// if run on a machine with certain environment variable settings. | ||
originalEnv = process.env; |
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.
Assigning process.env directly to originalEnv stores a reference instead of a snapshot, which may lead to unintended side effects. Consider using a shallow copy (e.g., originalEnv = { ...process.env }) to ensure the original environment is accurately restored.
originalEnv = process.env; | |
originalEnv = { ...process.env }; |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
The tests in kubernetes-client#2288 can fail depending on the environment variables on the system. This commit takes the environment out of the equation. Refs: kubernetes-client#2288
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brendandburns, cjihrig 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 |
The tests in #2288 can fail depending on the environment variables on the system. This commit takes the environment out of the equation.
Refs: #2288