From: Ardis Lu Date: Sun, 16 Aug 2026 07:15:37 +0000 (-0700) Subject: Add `injectInProcess` unit tests X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=59052fe5d55d20e3b947967d7bb9f7a648ec42e5;p=envpass Add `injectInProcess` unit tests --- diff --git a/test/index.test.js b/test/index.test.js index 04d143c..e1bf226 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -168,6 +168,24 @@ suite('decrypt', () => { await opened; t.mock.timers.tick(WINDOW_EXPIRATION_DURATION); }); + test('injects environment variables', async (t) => { + const envFile = await setupEnv(t, 'INJECTION_TEST=INJECTED'); + assertConsole(t, { debug: 0, info: 0, warn: 0, error: 0 }); + + deepStrictEqual(process.env.INJECTION_TEST, undefined); + await decrypt({ inFile: envFile, injectInProcess: true }); + deepStrictEqual(process.env.INJECTION_TEST, 'INJECTED'); + delete process.env.INJECTION_TEST; + }); + test('injects environment variables (with logs)', async (t) => { + const envFile = await setupEnv(t, 'INJECTION_TEST=INJECTED'); + assertConsole(t, { debug: 3, info: 0, warn: 0, error: 0 }); + + deepStrictEqual(process.env.INJECTION_TEST, undefined); + await decrypt({ inFile: envFile, injectInProcess: true, logger: console }); + deepStrictEqual(process.env.INJECTION_TEST, 'INJECTED'); + delete process.env.INJECTION_TEST; + }); test('passes through excess args to execute', async (t) => { const execMock = t.mock.method(childProcess, 'execSync', () => { }); const envFile = await setupEnv(t, STD_ENV);