@@ -82,6 +82,7 @@ describe('Scf', () => {
8282 bucket : process . env . BUCKET ,
8383 object : 'express_code.zip' ,
8484 } ,
85+ namespace : 'test' ,
8586 role : 'SCF_QcsRole' ,
8687 handler : 'sl_handler.handler' ,
8788 runtime : 'Nodejs12.16' ,
@@ -161,7 +162,7 @@ describe('Scf', () => {
161162 Qualifier : '$LATEST' ,
162163 Description : 'Created by Serverless Framework' ,
163164 Timeout : inputs . timeout ,
164- InitTimeout : 0 ,
165+ InitTimeout : expect . any ( Number ) ,
165166 MemorySize : inputs . memorySize ,
166167 Runtime : inputs . runtime ,
167168 VpcConfig : { VpcId : vpcConfig . vpcId , SubnetId : vpcConfig . subnetId } ,
@@ -182,7 +183,7 @@ describe('Scf', () => {
182183 CodeSize : 0 ,
183184 FunctionVersion : '$LATEST' ,
184185 FunctionName : inputs . name ,
185- Namespace : 'default ' ,
186+ Namespace : 'test ' ,
186187 InstallDependency : 'FALSE' ,
187188 Status : 'Active' ,
188189 // Status: expect.any(String),
@@ -325,8 +326,180 @@ describe('Scf', () => {
325326 // },
326327 ] ) ;
327328 } ) ;
329+ test ( 'should update SCF success' , async ( ) => {
330+ await sleep ( 3000 ) ;
331+ outputs = await scf . deploy ( inputs ) ;
332+ expect ( outputs ) . toEqual ( {
333+ Qualifier : '$LATEST' ,
334+ Description : 'Created by Serverless Framework' ,
335+ Timeout : inputs . timeout ,
336+ InitTimeout : expect . any ( Number ) ,
337+ MemorySize : inputs . memorySize ,
338+ Runtime : inputs . runtime ,
339+ VpcConfig : { VpcId : vpcConfig . vpcId , SubnetId : vpcConfig . subnetId } ,
340+ Environment : {
341+ Variables : [
342+ {
343+ Key : 'TEST' ,
344+ Value : 'value' ,
345+ } ,
346+ ] ,
347+ } ,
348+ Handler : inputs . handler ,
349+ AsyncRunEnable : 'FALSE' ,
350+ LogType : expect . any ( String ) ,
351+ TraceEnable : 'FALSE' ,
352+ UseGpu : 'FALSE' ,
353+ Role : inputs . role ,
354+ CodeSize : 0 ,
355+ FunctionVersion : '$LATEST' ,
356+ FunctionName : inputs . name ,
357+ Namespace : 'test' ,
358+ InstallDependency : 'FALSE' ,
359+ Status : 'Active' ,
360+ // Status: expect.any(String),
361+ AvailableStatus : 'Available' ,
362+ StatusDesc : expect . any ( String ) ,
363+ FunctionId : expect . stringContaining ( 'lam-' ) ,
364+ L5Enable : 'FALSE' ,
365+ EipConfig : { EipFixed : 'TRUE' , Eips : expect . any ( Array ) } ,
366+ ModTime : expect . any ( String ) ,
367+ AddTime : expect . any ( String ) ,
368+ Layers : [
369+ {
370+ LayerName : layerInputs . name ,
371+ LayerVersion : expect . any ( Number ) ,
372+ CompatibleRuntimes : layerInputs . runtimes ,
373+ Description : layerInputs . description ,
374+ LicenseInfo : '' ,
375+ AddTime : expect . any ( String ) ,
376+ Status : 'Active' ,
377+ Src : 'Default' ,
378+ } ,
379+ ] ,
380+ DeadLetterConfig : { Type : '' , Name : '' , FilterType : '' } ,
381+ OnsEnable : 'FALSE' ,
382+ PublicNetConfig : {
383+ PublicNetStatus : 'ENABLE' ,
384+ EipConfig : { EipStatus : 'ENABLE' , EipAddress : expect . any ( Array ) } ,
385+ } ,
386+ Triggers : expect . any ( Array ) ,
387+ ClsLogsetId : expect . any ( String ) ,
388+ ClsTopicId : expect . any ( String ) ,
389+ CodeInfo : '' ,
390+ CodeResult : 'success' ,
391+ CodeError : '' ,
392+ ErrNo : 0 ,
393+ Tags : [
394+ {
395+ Key : 'test' ,
396+ Value : 'test' ,
397+ } ,
398+ ] ,
399+ AccessInfo : { Host : '' , Vip : '' } ,
400+ Type : 'Event' ,
401+ CfsConfig : {
402+ CfsInsList : [
403+ {
404+ UserId : '10000' ,
405+ UserGroupId : '10000' ,
406+ CfsId : inputs . cfs [ 0 ] . cfsId ,
407+ MountInsId : inputs . cfs [ 0 ] . cfsId ,
408+ LocalMountDir : inputs . cfs [ 0 ] . localMountDir ,
409+ RemoteMountDir : inputs . cfs [ 0 ] . remoteMountDir ,
410+ IpAddress : expect . any ( String ) ,
411+ MountVpcId : inputs . vpcConfig . vpcId ,
412+ MountSubnetId : inputs . vpcConfig . subnetId ,
413+ } ,
414+ ] ,
415+ } ,
416+ StatusReasons : [ ] ,
417+ RequestId : expect . any ( String ) ,
418+ LastVersion : '2' ,
419+ Traffic : inputs . traffic ,
420+ ConfigTrafficVersion : '2' ,
421+ } ) ;
422+
423+ // expect triggers result
424+ expect ( outputs . Triggers ) . toEqual ( [
425+ {
426+ NeedCreate : expect . any ( Boolean ) ,
427+ created : true ,
428+ serviceId : expect . stringContaining ( 'service-' ) ,
429+ serviceName : 'serverless_test' ,
430+ subDomain : expect . stringContaining ( '.apigw.tencentcs.com' ) ,
431+ protocols : 'http' ,
432+ environment : 'release' ,
433+ apiList : [
434+ {
435+ path : '/' ,
436+ internalDomain : expect . any ( String ) ,
437+ method : 'GET' ,
438+ apiName : 'index' ,
439+ apiId : expect . stringContaining ( 'api-' ) ,
440+ created : true ,
441+ authType : 'NONE' ,
442+ businessType : 'NORMAL' ,
443+ isBase64Encoded : false ,
444+ } ,
445+ ] ,
446+ } ,
447+ {
448+ NeedCreate : expect . any ( Boolean ) ,
449+ AddTime : expect . any ( String ) ,
450+ AvailableStatus : expect . any ( String ) ,
451+ CustomArgument : triggers . timer . timer . parameters . argument ,
452+ Enable : 1 ,
453+ ModTime : expect . any ( String ) ,
454+ TriggerDesc : `{"cron":"${ triggers . timer . timer . parameters . cronExpression } "}` ,
455+ TriggerName : triggers . timer . timer . name ,
456+ Type : 'timer' ,
457+ BindStatus : expect . any ( String ) ,
458+ ResourceId : expect . any ( String ) ,
459+ TriggerAttribute : expect . any ( String ) ,
460+ Qualifier : expect . any ( String ) ,
461+ } ,
462+ {
463+ NeedCreate : expect . any ( Boolean ) ,
464+ AddTime : expect . any ( String ) ,
465+ AvailableStatus : expect . any ( String ) ,
466+ CustomArgument : expect . any ( String ) ,
467+ Enable : 1 ,
468+ ModTime : expect . any ( String ) ,
469+ TriggerDesc : `{"bucketUrl":"${ triggers . cos . cos . parameters . bucket } ","event":"${ triggers . cos . cos . parameters . events } ","filter":{"Prefix":"${ triggers . cos . cos . parameters . filter . prefix } ","Suffix":"${ triggers . cos . cos . parameters . filter . suffix } "}}` ,
470+ TriggerName : expect . stringContaining ( 'cos' ) ,
471+ Type : 'cos' ,
472+ BindStatus : expect . any ( String ) ,
473+ ResourceId : expect . any ( String ) ,
474+ TriggerAttribute : expect . any ( String ) ,
475+ Qualifier : expect . any ( String ) ,
476+ } ,
477+ {
478+ NeedCreate : expect . any ( Boolean ) ,
479+ enable : triggers . cls . cls . parameters . enable ,
480+ namespace : inputs . namespace || 'default' ,
481+ functionName : inputs . name ,
482+ maxSize : triggers . cls . cls . parameters . maxSize ,
483+ maxWait : triggers . cls . cls . parameters . maxWait ,
484+ qualifier : triggers . cls . cls . parameters . qualifier ,
485+ topicId : triggers . cls . cls . parameters . topicId ,
486+ Qualifier : expect . any ( String ) ,
487+ } ,
488+ // {
489+ // enable: triggers.mps.mps.parameters.enable,
490+ // namespace: inputs.namespace || 'default',
491+ // functionName: inputs.name,
492+ // qualifier: triggers.mps.mps.parameters.qualifier,
493+ // type: triggers.mps.mps.parameters.type,
494+ // resourceId: expect.stringContaining(
495+ // `TriggerType/${triggers.mps.mps.parameters.type}Event`,
496+ // ),
497+ // },
498+ ] ) ;
499+ } ) ;
328500 test ( 'should invoke Scf success' , async ( ) => {
329501 const res = await scf . invoke ( {
502+ namespace : inputs . namespace ,
330503 functionName : inputs . name ,
331504 } ) ;
332505 expect ( res ) . toEqual ( {
0 commit comments