@@ -82,6 +82,7 @@ describe('Scf', () => {
82
82
bucket : process . env . BUCKET ,
83
83
object : 'express_code.zip' ,
84
84
} ,
85
+ namespace : 'test' ,
85
86
role : 'SCF_QcsRole' ,
86
87
handler : 'sl_handler.handler' ,
87
88
runtime : 'Nodejs12.16' ,
@@ -161,7 +162,7 @@ describe('Scf', () => {
161
162
Qualifier : '$LATEST' ,
162
163
Description : 'Created by Serverless Framework' ,
163
164
Timeout : inputs . timeout ,
164
- InitTimeout : 0 ,
165
+ InitTimeout : expect . any ( Number ) ,
165
166
MemorySize : inputs . memorySize ,
166
167
Runtime : inputs . runtime ,
167
168
VpcConfig : { VpcId : vpcConfig . vpcId , SubnetId : vpcConfig . subnetId } ,
@@ -182,7 +183,7 @@ describe('Scf', () => {
182
183
CodeSize : 0 ,
183
184
FunctionVersion : '$LATEST' ,
184
185
FunctionName : inputs . name ,
185
- Namespace : 'default ' ,
186
+ Namespace : 'test ' ,
186
187
InstallDependency : 'FALSE' ,
187
188
Status : 'Active' ,
188
189
// Status: expect.any(String),
@@ -325,8 +326,180 @@ describe('Scf', () => {
325
326
// },
326
327
] ) ;
327
328
} ) ;
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
+ } ) ;
328
500
test ( 'should invoke Scf success' , async ( ) => {
329
501
const res = await scf . invoke ( {
502
+ namespace : inputs . namespace ,
330
503
functionName : inputs . name ,
331
504
} ) ;
332
505
expect ( res ) . toEqual ( {
0 commit comments