@@ -307,6 +307,39 @@ describe("cloudfunctionsv2", () => {
307307 expect ( reverted . vpc ) . to . deep . equal ( endpointWithNi . vpc ) ;
308308 } ) ;
309309
310+ it ( "should throw on unexpected VPC egress setting" , ( ) => {
311+ expect ( ( ) => {
312+ cloudfunctionsv2 . endpointFromFunction ( {
313+ ...HAVE_CLOUD_FUNCTION_V2 ,
314+ serviceConfig : {
315+ ...HAVE_CLOUD_FUNCTION_V2 . serviceConfig ,
316+ directVpcNetworkInterface : [ { network : "my-net" } ] ,
317+ directVpcEgress : "ALL_TRAFFIC" as any ,
318+ uri : RUN_URI ,
319+ service : "service" ,
320+ } ,
321+ } as cloudfunctionsv2 . OutputCloudFunction ) ;
322+ } ) . to . throw ( "Unexpected VPC egress setting: ALL_TRAFFIC" ) ;
323+ } ) ;
324+
325+ it ( "should ignore VPC_EGRESS_UNSPECIFIED" , ( ) => {
326+ const gcf = {
327+ ...HAVE_CLOUD_FUNCTION_V2 ,
328+ serviceConfig : {
329+ ...HAVE_CLOUD_FUNCTION_V2 . serviceConfig ,
330+ directVpcNetworkInterface : [ { network : "my-net" } ] ,
331+ directVpcEgress : "VPC_EGRESS_UNSPECIFIED" as any ,
332+ uri : RUN_URI ,
333+ service : "service" ,
334+ } ,
335+ } as cloudfunctionsv2 . OutputCloudFunction ;
336+ const endpoint = cloudfunctionsv2 . endpointFromFunction ( gcf ) ;
337+ expect ( endpoint . vpc ) . to . deep . equal ( {
338+ networkInterfaces : [ { network : "my-net" } ] ,
339+ } ) ;
340+ expect ( endpoint . vpc ?. egressSettings ) . to . be . undefined ;
341+ } ) ;
342+
310343 it ( "should calculate non-trivial fields" , ( ) => {
311344 const complexEndpoint : backend . Endpoint = {
312345 ...ENDPOINT ,
0 commit comments