-
Notifications
You must be signed in to change notification settings - Fork 104
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: delete env var after test if it was not set #774
fix: delete env var after test if it was not set #774
Conversation
c84b438
to
ba69cd0
Compare
Codecov Report
@@ Coverage Diff @@
## master #774 +/- ##
=======================================
Coverage 74.58% 74.58%
=======================================
Files 43 43
Lines 20220 20220
Branches 546 546
=======================================
Hits 15082 15082
Misses 5133 5133
Partials 5 5 Continue to review full report at Codecov.
|
LGTM! proposing wrap these 5 tests in a describe('SPANNER_EMULATOR_HOST', () => {
let currentEmulator: string | undefined;
beforeEach(() => (currentEmulator = process.env.SPANNER_EMULATOR_HOST));
afterEach(() => {
if (currentEmulator) {
process.env.SPANNER_EMULATOR_HOST = currentEmulator;
} else {
delete process.env.SPANNER_EMULATOR_HOST;
}
});
it('should parse emulator host without port correctly', () => {
const EMULATOR_HOST = 'somehost.local';
process.env.SPANNER_EMULATOR_HOST = `${EMULATOR_HOST}`;
const emulator = Spanner.getSpannerEmulatorHost();
assert.deepStrictEqual(emulator, {endpoint: EMULATOR_HOST});
});
}); |
…js-spanner into delete-env-var-after-test
Done. |
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.
* fix: delete env var after test if it was not set * fix: wrap tests in suite Co-authored-by: Benjamin E. Coe <[email protected]>
Delete the environment variable
SPANNER_EMULATOR_HOST
after a test instead of setting it toundefined
when it was not defined in the first place. Setting the environment variable toundefined
will convert it to the string 'undefined' and could affect other test cases, as they would see the environment variable as having been set.