@@ -139,6 +139,70 @@ describe('OpenWhiskCompileFunctions', () => {
139139 } ) ;
140140
141141 describe ( '#compileFunctions()' , ( ) => {
142+ it ( 'should create action function with parsed parameters' , ( ) => {
143+ let functionObject = {
144+ handler : "foo.js" ,
145+ name : "name" ,
146+ namespace : "namespace" ,
147+ overwrite : "overwrite" ,
148+ memory : 123 ,
149+ concurrency : 456 ,
150+ timeout : 789 ,
151+ parameters : {
152+ hello : "world" ,
153+ foo : "bar"
154+ } ,
155+ annotations : {
156+ hello : "world" ,
157+ foo : "bar"
158+ }
159+ } ;
160+
161+ openwhiskCompileFunctions . serverless . service . getAllFunctions = ( ) => [ 'service_name' ] ;
162+ openwhiskCompileFunctions . serverless . service . getFunction = ( ) => functionObject ;
163+ sandbox . stub ( openwhiskCompileFunctions , 'runtimes' , {
164+ exec : ( ) => Promise . resolve ( )
165+ } ) ;
166+
167+ return openwhiskCompileFunctions . compileFunctions ( ) . then ( functionActions => {
168+ let functionAction = functionActions [ 0 ] ;
169+ expect ( functionAction . actionName ) . to . be . equal ( functionObject . name ) ;
170+ expect ( functionAction . namespace ) . to . be . equal ( functionObject . namespace ) ;
171+ expect ( functionAction . overwrite ) . to . be . equal ( functionObject . overwrite ) ;
172+ expect ( functionAction . action . limits . memory ) . to . be . equal ( functionObject . memory ) ;
173+ expect ( functionAction . action . limits . concurrency ) . to . be . equal ( functionObject . concurrency ) ;
174+ expect ( functionAction . action . limits . timeout ) . to . be . equal ( functionObject . timeout * 1000 ) ;
175+
176+ let paramsAndAnnotations = [
177+ { key : 'hello' , value : 'world' } ,
178+ { key : 'foo' , value : 'bar' }
179+ ] ;
180+ expect ( functionAction . action . parameters ) . to . deep . equal ( paramsAndAnnotations ) ;
181+ expect ( functionAction . action . annotations ) . to . deep . equal ( paramsAndAnnotations ) ;
182+ } ) ;
183+ } ) ;
184+
185+ it ( 'should not add implicit limits parameters' , ( ) => {
186+ let functionObject = {
187+ handler : "foo.js" ,
188+ name : "name"
189+ } ;
190+
191+ openwhiskCompileFunctions . serverless . service . getAllFunctions = ( ) => [ 'service_name' ] ;
192+ openwhiskCompileFunctions . serverless . service . getFunction = ( ) => functionObject ;
193+ sandbox . stub ( openwhiskCompileFunctions , 'runtimes' , {
194+ exec : ( ) => Promise . resolve ( )
195+ } ) ;
196+
197+ return openwhiskCompileFunctions . compileFunctions ( ) . then ( functionActions => {
198+ let functionAction = functionActions [ 0 ] ;
199+ expect ( functionAction . actionName ) . to . be . equal ( functionObject . name ) ;
200+ expect ( functionAction . action . limits . memory ) . to . be . undefined ;
201+ expect ( functionAction . action . limits . concurrency ) . to . be . undefined ;
202+ expect ( functionAction . action . limits . timeout ) . to . be . undefined ;
203+ } ) ;
204+ } ) ;
205+
142206 it ( 'should throw an error if the resource section is not available' , ( ) => {
143207 openwhiskCompileFunctions . serverless . service . actions = null ;
144208 expect ( ( ) => openwhiskCompileFunctions . compileFunctions ( ) )
0 commit comments