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', () => {
3434 } ) ;
3535 } ) ;
3636
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+
3775 test ( 'should delete trigger success' , async ( ) => {
3876 const { Triggers = [ ] } = await scfClient . request ( {
3977 Action : 'ListTriggers' ,
Original file line number Diff line number Diff line change @@ -70,9 +70,26 @@ class MpsTrigger extends BaseTrigger {
7070 namespace : inputs . namespace || 'default' ,
7171 functionName : inputs . functionName ,
7272 } ) ;
73+ let needBind = false ;
7374 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+ }
7487 output . resourceId = existTypeTrigger . ResourceId ;
7588 } else {
89+ needBind = true ;
90+ }
91+
92+ if ( needBind ) {
7693 const res = await this . request ( {
7794 Action : 'BindTrigger' ,
7895 ScfRegion : this . region ,
You can’t perform that action at this time.
0 commit comments