|
1 | 1 | import { GlobalConfig } from '../../config/global.ts'; |
2 | | -import { getChildProcessEnv } from './env.ts'; |
| 2 | +import { |
| 3 | + basicEnvVars, |
| 4 | + getChildProcessEnv, |
| 5 | + hardcodedProcessEnv, |
| 6 | +} from './env.ts'; |
3 | 7 |
|
4 | 8 | describe('util/exec/env', () => { |
5 | 9 | const envVars = [ |
@@ -51,7 +55,25 @@ describe('util/exec/env', () => { |
51 | 55 | 'PROGRAMFILES(X86)': 'PROGRAMFILES(X86)', |
52 | 56 | APPDATA: 'APPDATA', |
53 | 57 | LOCALAPPDATA: 'LOCALAPPDATA', |
| 58 | + |
| 59 | + CI: 'true', |
| 60 | + }); |
| 61 | + }); |
| 62 | + |
| 63 | + it('always sets static values for CI', () => { |
| 64 | + expect(getChildProcessEnv()).toMatchObject({ |
| 65 | + CI: 'true', |
| 66 | + }); |
| 67 | + }); |
| 68 | + |
| 69 | + it('static environment variables override the process environment variables', () => { |
| 70 | + process.env.CI = 'false'; |
| 71 | + |
| 72 | + expect(getChildProcessEnv()).toMatchObject({ |
| 73 | + CI: 'true', |
54 | 74 | }); |
| 75 | + |
| 76 | + delete process.env.CI; |
55 | 77 | }); |
56 | 78 |
|
57 | 79 | it('returns environment variable only if defined', () => { |
@@ -81,4 +103,22 @@ describe('util/exec/env', () => { |
81 | 103 | expect(getChildProcessEnv()).toMatchObject(process.env); |
82 | 104 | }); |
83 | 105 | }); |
| 106 | + |
| 107 | + describe('basicEnvVars and hardcodedProcessEnv should not have any overlap', () => { |
| 108 | + describe('basicEnvVars does not include any environment variables in hardcodedProcessEnv', () => { |
| 109 | + for (const env of Object.keys(hardcodedProcessEnv)) { |
| 110 | + it(`${env} is not in basicEnvVars`, () => { |
| 111 | + expect(basicEnvVars).not.toContain(env); |
| 112 | + }); |
| 113 | + } |
| 114 | + }); |
| 115 | + |
| 116 | + describe('hardcodedProcessEnv does not include any environment variables in basicEnvVars', () => { |
| 117 | + for (const env of basicEnvVars) { |
| 118 | + it(`${env} is not in hardcodedProcessEnv`, () => { |
| 119 | + expect(hardcodedProcessEnv).not.toContainKey(env); |
| 120 | + }); |
| 121 | + } |
| 122 | + }); |
| 123 | + }); |
84 | 124 | }); |
0 commit comments