File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ describe('index', () => {
67
67
68
68
import './lifecycle.spec' ;
69
69
import './main.spec' ;
70
+ import './secretmanager.spec' ;
70
71
import './v2.spec' ;
71
72
import './cloudevent/generate' ;
72
73
import './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