File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,44 @@ describe('Mps', () => {
34
34
} ) ;
35
35
} ) ;
36
36
37
+ test ( 'should disable trigger success' , async ( ) => {
38
+ data . enable = false ;
39
+ const res = await client . create ( {
40
+ inputs : {
41
+ namespace : namespace ,
42
+ functionName : functionName ,
43
+ parameters : data ,
44
+ } ,
45
+ } ) ;
46
+ expect ( res ) . toEqual ( {
47
+ enable : false ,
48
+ namespace : namespace ,
49
+ functionName : functionName ,
50
+ qualifier : '$DEFAULT' ,
51
+ type : data . type ,
52
+ resourceId : expect . stringContaining ( `TriggerType/${ data . type } ` ) ,
53
+ } ) ;
54
+ } ) ;
55
+
56
+ test ( 'should enable trigger success' , async ( ) => {
57
+ data . enable = true ;
58
+ const res = await client . create ( {
59
+ inputs : {
60
+ namespace : namespace ,
61
+ functionName : functionName ,
62
+ parameters : data ,
63
+ } ,
64
+ } ) ;
65
+ expect ( res ) . toEqual ( {
66
+ enable : true ,
67
+ namespace : namespace ,
68
+ functionName : functionName ,
69
+ qualifier : '$DEFAULT' ,
70
+ type : data . type ,
71
+ resourceId : expect . stringContaining ( `TriggerType/${ data . type } ` ) ,
72
+ } ) ;
73
+ } ) ;
74
+
37
75
test ( 'should delete trigger success' , async ( ) => {
38
76
const { Triggers = [ ] } = await scfClient . request ( {
39
77
Action : 'ListTriggers' ,
Original file line number Diff line number Diff line change @@ -70,9 +70,26 @@ class MpsTrigger extends BaseTrigger {
70
70
namespace : inputs . namespace || 'default' ,
71
71
functionName : inputs . functionName ,
72
72
} ) ;
73
+ let needBind = false ;
73
74
if ( existTypeTrigger ) {
75
+ if ( data . enable === false ) {
76
+ await this . request ( {
77
+ Action : 'UnbindTrigger' ,
78
+ Type : 'mps' ,
79
+ Qualifier : data . qualifier || '$DEFAULT' ,
80
+ FunctionName : inputs . functionName ,
81
+ Namespace : inputs . namespace || 'default' ,
82
+ ResourceId : existTypeTrigger . ResourceId ,
83
+ } ) ;
84
+ } else if ( existTypeTrigger . BindStatus === 'off' ) {
85
+ needBind = true ;
86
+ }
74
87
output . resourceId = existTypeTrigger . ResourceId ;
75
88
} else {
89
+ needBind = true ;
90
+ }
91
+
92
+ if ( needBind ) {
76
93
const res = await this . request ( {
77
94
Action : 'BindTrigger' ,
78
95
ScfRegion : this . region ,
You can’t perform that action at this time.
0 commit comments