Skip to content

Commit 07026be

Browse files
committed
add sanity tests for util
1 parent 622c4d2 commit 07026be

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
import assert from 'assert'
6+
import { envWithNewPath, readEnv, setEnv } from '../../testUtil'
7+
8+
describe('envWithNewPath', function () {
9+
it('gives current path with new PATH', function () {
10+
const fakePath = 'fakePath'
11+
assert.deepStrictEqual(envWithNewPath(fakePath), { ...process.env, PATH: fakePath })
12+
})
13+
})
14+
15+
describe('writeEnv', function () {
16+
it('modifies the node environment variables', function () {
17+
const originalEnv = readEnv()
18+
const fakePath = 'fakePath'
19+
setEnv(envWithNewPath('fakePath'))
20+
assert.strictEqual(readEnv().PATH, fakePath)
21+
22+
setEnv(originalEnv)
23+
assert.deepStrictEqual(readEnv(), originalEnv)
24+
})
25+
})

packages/core/src/test/testUtil.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { mkdirSync, existsSync } from 'fs' // eslint-disable-line no-restricted-
1919
import { randomBytes } from 'crypto'
2020
import request from '../shared/request'
2121
import { stub } from 'sinon'
22-
import { isWin } from '../shared/vscode/env'
2322

2423
const testTempDirs: string[] = []
2524

@@ -625,5 +624,5 @@ export function readEnv(): NodeJS.ProcessEnv {
625624
}
626625

627626
export function envWithNewPath(newPath: string): NodeJS.ProcessEnv {
628-
return isWin() ? { ...process.env, Path: newPath } : { ...process.env, PATH: newPath }
627+
return { ...process.env, PATH: newPath }
629628
}

0 commit comments

Comments
 (0)