@@ -16,17 +16,24 @@ describe('deployTriggers', () => {
16
16
triggers : {
17
17
myTrigger : {
18
18
triggerName : 'myTrigger' ,
19
- namepspace : 'myNamespace' ,
19
+ namespace : 'myNamespace' ,
20
20
action : 'myAction' ,
21
21
trigger : 'myTrigger' ,
22
22
} ,
23
+ feedTrigger : {
24
+ triggerName : 'myTrigger' ,
25
+ namespace : 'myNamespace' ,
26
+ action : 'myAction' ,
27
+ trigger : 'myTrigger' ,
28
+ feed : '/whisk.system/alarms/alarm' ,
29
+ } ,
23
30
} ,
24
31
} ;
25
32
26
33
beforeEach ( ( ) => {
27
34
sandbox = sinon . sandbox . create ( ) ;
28
- const CLI = function ( ) { this . log = function ( ) { } ; } ;
29
- serverless = { classes : { Error, CLI } , service : { provider : { } , resources : { } , getAllFunctions : ( ) => [ ] } , getProvider : sandbox . spy ( ) } ;
35
+ const CLI = function ( ) { this . log = function ( ) { } ; } ;
36
+ serverless = { classes : { Error, CLI } , service : { provider : { } , resources : { } , getAllFunctions : ( ) => [ ] } , getProvider : sandbox . spy ( ) } ;
30
37
const options = {
31
38
stage : 'dev' ,
32
39
region : 'us-east-1' ,
@@ -38,7 +45,7 @@ describe('deployTriggers', () => {
38
45
apihost : 'openwhisk.org' ,
39
46
auth : 'user:pass' ,
40
47
} ;
41
- openwhiskDeploy . provider = { client : ( ) => { } }
48
+ openwhiskDeploy . provider = { client : ( ) => { } } ;
42
49
} ) ;
43
50
44
51
afterEach ( ( ) => {
@@ -73,23 +80,33 @@ describe('deployTriggers', () => {
73
80
} ) ;
74
81
75
82
it ( 'should log function deploy information with verbose flag' , ( ) => {
76
- openwhiskDeploy . options . verbose = true
77
- const log = sandbox . stub ( openwhiskDeploy . serverless . cli , 'log' )
78
- const clog = sandbox . stub ( openwhiskDeploy . serverless . cli , 'consoleLog' )
83
+ openwhiskDeploy . options . verbose = true ;
84
+ const log = sandbox . stub ( openwhiskDeploy . serverless . cli , 'log' ) ;
85
+ const clog = sandbox . stub ( openwhiskDeploy . serverless . cli , 'consoleLog' ) ;
79
86
sandbox . stub ( openwhiskDeploy . provider , 'client' , ( ) => {
80
- const create = params => {
81
- return Promise . resolve ( ) ;
82
- } ;
87
+ const create = params => Promise . resolve ( ) ;
83
88
84
89
return Promise . resolve ( { triggers : { create } } ) ;
85
90
} ) ;
86
91
87
92
return openwhiskDeploy . deployTrigger ( mockTriggerObject . triggers . myTrigger ) . then ( ( ) => {
88
- expect ( log . calledTwice ) . to . be . equal ( true ) ;
89
- expect ( log . args [ 0 ] [ 0 ] ) . to . be . equal ( 'Deploying Trigger: myTrigger' )
90
- expect ( log . args [ 1 ] [ 0 ] ) . to . be . equal ( 'Deployed Trigger: myTrigger' )
91
- } )
92
- } )
93
+ expect ( log . calledTwice ) . to . be . equal ( true ) ;
94
+ expect ( log . args [ 0 ] [ 0 ] ) . to . be . equal ( 'Deploying Trigger: myTrigger' ) ;
95
+ expect ( log . args [ 1 ] [ 0 ] ) . to . be . equal ( 'Deployed Trigger: myTrigger' ) ;
96
+ } ) ;
97
+ } ) ;
93
98
99
+ it ( 'should deploy trigger with feed annotation to openwhisk' , ( ) => {
100
+ sandbox . stub ( openwhiskDeploy . provider , 'client' , ( ) => {
101
+ const create = params => {
102
+ expect ( params ) . to . be . deep . equal ( mockTriggerObject . triggers . feedTrigger ) ;
103
+ return Promise . resolve ( ) ;
104
+ } ;
105
+
106
+ return Promise . resolve ( { triggers : { create } } ) ;
107
+ } ) ;
108
+ return expect ( openwhiskDeploy . deployTrigger ( mockTriggerObject . triggers . feedTrigger ) )
109
+ . to . eventually . be . fulfilled ;
110
+ } ) ;
94
111
} ) ;
95
112
} ) ;
0 commit comments