@@ -1015,8 +1015,14 @@ test('should have only allowed environment variables set', async (t) => {
1015
1015
} ,
1016
1016
} )
1017
1017
. withEdgeFunction ( {
1018
- // eslint-disable-next-line no-undef
1019
- handler : ( ) => new Response ( `${ JSON . stringify ( Deno . env . toObject ( ) ) } ` ) ,
1018
+ handler : ( ) => {
1019
+ // eslint-disable-next-line no-undef
1020
+ const fromDenoGlobal = Deno . env . toObject ( )
1021
+ // eslint-disable-next-line no-undef
1022
+ const fromNetlifyGlobal = Netlify . env . toObject ( )
1023
+
1024
+ return new Response ( `${ JSON . stringify ( { fromDenoGlobal, fromNetlifyGlobal } ) } ` )
1025
+ } ,
1020
1026
name : 'env' ,
1021
1027
} )
1022
1028
. withContentFile ( {
@@ -1041,24 +1047,29 @@ test('should have only allowed environment variables set', async (t) => {
1041
1047
const response = await got ( `http://localhost:${ port } /env` ) . then ( ( edgeResponse ) =>
1042
1048
JSON . parse ( edgeResponse . body ) ,
1043
1049
)
1044
- const envKeys = Object . keys ( response )
1050
+ const buckets = Object . values ( response )
1051
+ t . is ( buckets . length , 2 )
1052
+
1053
+ buckets . forEach ( ( bucket ) => {
1054
+ const bucketKeys = Object . keys ( bucket )
1045
1055
1046
- t . true ( envKeys . includes ( 'DENO_REGION' ) )
1047
- t . is ( response . DENO_REGION , 'local' )
1056
+ t . true ( bucketKeys . includes ( 'DENO_REGION' ) )
1057
+ t . is ( bucket . DENO_REGION , 'local' )
1048
1058
1049
- t . true ( envKeys . includes ( 'NETLIFY_DEV' ) )
1050
- t . is ( response . NETLIFY_DEV , 'true' )
1059
+ t . true ( bucketKeys . includes ( 'NETLIFY_DEV' ) )
1060
+ t . is ( bucket . NETLIFY_DEV , 'true' )
1051
1061
1052
- t . true ( envKeys . includes ( 'SECRET_ENV' ) )
1053
- t . is ( response . SECRET_ENV , 'true' )
1062
+ t . true ( bucketKeys . includes ( 'SECRET_ENV' ) )
1063
+ t . is ( bucket . SECRET_ENV , 'true' )
1054
1064
1055
- t . true ( envKeys . includes ( 'FROM_ENV' ) )
1056
- t . is ( response . FROM_ENV , 'YAS' )
1065
+ t . true ( bucketKeys . includes ( 'FROM_ENV' ) )
1066
+ t . is ( bucket . FROM_ENV , 'YAS' )
1057
1067
1058
- t . false ( envKeys . includes ( 'DENO_DEPLOYMENT_ID' ) )
1059
- t . false ( envKeys . includes ( 'NODE_ENV' ) )
1060
- t . false ( envKeys . includes ( 'DEPLOY_URL' ) )
1061
- t . false ( envKeys . includes ( 'URL' ) )
1068
+ t . false ( bucketKeys . includes ( 'DENO_DEPLOYMENT_ID' ) )
1069
+ t . false ( bucketKeys . includes ( 'NODE_ENV' ) )
1070
+ t . false ( bucketKeys . includes ( 'DEPLOY_URL' ) )
1071
+ t . false ( bucketKeys . includes ( 'URL' ) )
1072
+ } )
1062
1073
} ,
1063
1074
)
1064
1075
} )
0 commit comments