File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ describe('index', () => {
6767
6868import './lifecycle.spec' ;
6969import './main.spec' ;
70+ import './secretmanager.spec' ;
7071import './v2.spec' ;
7172import './cloudevent/generate' ;
7273import './app.spec' ;
Original file line number Diff line number Diff line change 1+ import { expect } from 'chai' ;
2+ import { mockSecretManager } from '../src/secretManager' ;
3+
4+ describe ( 'mockSecretManager' , ( ) => {
5+ let originalEnv ;
6+
7+ before ( ( ) => {
8+ // Capture the original environment variables
9+ originalEnv = { ...process . env } ;
10+ } ) ;
11+
12+ afterEach ( ( ) => {
13+ // Reset any mutations made by the test run
14+ process . env = { ...originalEnv } ;
15+ } ) ;
16+
17+ it ( 'applies each key/value pair to process.env' , ( ) => {
18+ const conf = { FOO : 'bar' , BAZ : 'qux' } ;
19+
20+ mockSecretManager ( conf ) ;
21+
22+ expect ( process . env . FOO ) . to . equal ( 'bar' ) ;
23+ expect ( process . env . BAZ ) . to . equal ( 'qux' ) ;
24+ } ) ;
25+
26+ it ( 'overwrites an existing variable with the new value' , ( ) => {
27+ process . env . EXISTING = 'old' ;
28+ const conf = { EXISTING : 'new' } ;
29+
30+ mockSecretManager ( conf ) ;
31+
32+ expect ( process . env . EXISTING ) . to . equal ( 'new' ) ;
33+ } ) ;
34+
35+ it ( 'supports non-string values (coerced to string)' , ( ) => {
36+ const conf : Record < string , string > = { NUM_VALUE : '123' , BOOL_VALUE : 'true' } ;
37+
38+ mockSecretManager ( conf ) ;
39+
40+ expect ( process . env . NUM_VALUE ) . to . equal ( '123' ) ;
41+ expect ( process . env . BOOL_VALUE ) . to . equal ( 'true' ) ;
42+ } ) ;
43+ } ) ;
You can’t perform that action at this time.
0 commit comments