|
4 | 4 | */
|
5 | 5 |
|
6 | 6 | import assert from 'assert'
|
7 |
| -import { getServiceEnvVarConfig } from '../../../shared/vscode/env' |
| 7 | +import { getEnvVars, getServiceEnvVarConfig } from '../../../shared/vscode/env' |
8 | 8 |
|
9 |
| -describe('getServiceEnvVarConfig', function () { |
10 |
| - const envVars: string[] = [] |
| 9 | +describe('env', function () { |
| 10 | + describe('getServiceEnvVarConfig', function () { |
| 11 | + const envVars: string[] = [] |
11 | 12 |
|
12 |
| - afterEach(() => { |
13 |
| - envVars.forEach(v => delete process.env[v]) |
14 |
| - envVars.length = 0 |
| 13 | + afterEach(() => { |
| 14 | + envVars.forEach(v => delete process.env[v]) |
| 15 | + envVars.length = 0 |
| 16 | + }) |
| 17 | + |
| 18 | + function addEnvVar(k: string, v: string) { |
| 19 | + process.env[k] = v |
| 20 | + envVars.push(k) |
| 21 | + } |
| 22 | + |
| 23 | + it('gets service config', async function () { |
| 24 | + const service = 'codecatalyst' |
| 25 | + const serviceConfigs = ['region', 'endpoint', 'gitHostname'] |
| 26 | + addEnvVar('__CODECATALYST_ENDPOINT', 'test.endpoint') |
| 27 | + addEnvVar('__CODECATALYST_GIT_HOSTNAME', 'test.gitHostname') |
| 28 | + |
| 29 | + const expectedConfig = { |
| 30 | + endpoint: 'test.endpoint', |
| 31 | + gitHostname: 'test.gitHostname', |
| 32 | + } |
| 33 | + assert.deepStrictEqual(getServiceEnvVarConfig(service, serviceConfigs), expectedConfig) |
| 34 | + }) |
15 | 35 | })
|
16 | 36 |
|
17 |
| - function addEnvVar(k: string, v: string) { |
18 |
| - process.env[k] = v |
19 |
| - envVars.push(k) |
20 |
| - } |
| 37 | + describe('getEnvVars', function () { |
| 38 | + it('gets codecatalyst environment variables', async function () { |
| 39 | + const expectedEnvVars = { |
| 40 | + region: '__CODECATALYST_REGION', |
| 41 | + endpoint: '__CODECATALYST_ENDPOINT', |
| 42 | + hostname: '__CODECATALYST_HOSTNAME', |
| 43 | + gitHostname: '__CODECATALYST_GIT_HOSTNAME', |
| 44 | + } |
21 | 45 |
|
22 |
| - it('gets service config', async function () { |
23 |
| - const service = 'codecatalyst' |
24 |
| - const configToEnvMap = { |
25 |
| - region: '__CODECATALYST_REGION', |
26 |
| - endpoint: '__CODECATALYST_ENDPOINT', |
27 |
| - } |
28 |
| - addEnvVar('__CODECATALYST_ENDPOINT', 'test.endpoint') |
| 46 | + const envVar = getEnvVars('codecatalyst', Object.keys(expectedEnvVars)) |
| 47 | + assert.deepStrictEqual(envVar, expectedEnvVars) |
| 48 | + }) |
29 | 49 |
|
30 |
| - const expectedConfig = { |
31 |
| - endpoint: 'test.endpoint', |
32 |
| - } |
33 |
| - assert.deepStrictEqual(getServiceEnvVarConfig(service, configToEnvMap), expectedConfig) |
| 50 | + it('gets codewhisperer environment variables', async function () { |
| 51 | + const expectedEnvVars = { |
| 52 | + region: '__CODEWHISPERER_REGION', |
| 53 | + endpoint: '__CODEWHISPERER_ENDPOINT', |
| 54 | + } |
| 55 | + const envVar = getEnvVars('codewhisperer', Object.keys(expectedEnvVars)) |
| 56 | + assert.deepStrictEqual(envVar, expectedEnvVars) |
| 57 | + }) |
34 | 58 | })
|
35 | 59 | })
|
0 commit comments