@@ -222,4 +222,66 @@ void describe('Conversation Handler Function construct', () => {
222
222
Handler : 'index.handler' ,
223
223
} ) ;
224
224
} ) ;
225
+
226
+ void describe ( 'memory property' , ( ) => {
227
+ void it ( 'sets valid memory' , ( ) => {
228
+ const app = new App ( ) ;
229
+ const stack = new Stack ( app ) ;
230
+ new ConversationHandlerFunction ( stack , 'conversationHandler' , {
231
+ models : [ ] ,
232
+ memoryMB : 234 ,
233
+ } ) ;
234
+ const template = Template . fromStack ( stack ) ;
235
+
236
+ template . hasResourceProperties ( 'AWS::Lambda::Function' , {
237
+ MemorySize : 234 ,
238
+ } ) ;
239
+ } ) ;
240
+
241
+ void it ( 'sets default memory' , ( ) => {
242
+ const app = new App ( ) ;
243
+ const stack = new Stack ( app ) ;
244
+ new ConversationHandlerFunction ( stack , 'conversationHandler' , {
245
+ models : [ ] ,
246
+ } ) ;
247
+ const template = Template . fromStack ( stack ) ;
248
+
249
+ template . hasResourceProperties ( 'AWS::Lambda::Function' , {
250
+ MemorySize : 512 ,
251
+ } ) ;
252
+ } ) ;
253
+
254
+ void it ( 'throws on memory below 128 MB' , ( ) => {
255
+ assert . throws ( ( ) => {
256
+ const app = new App ( ) ;
257
+ const stack = new Stack ( app ) ;
258
+ new ConversationHandlerFunction ( stack , 'conversationHandler' , {
259
+ models : [ ] ,
260
+ memoryMB : 127 ,
261
+ } ) ;
262
+ } , new Error ( 'memoryMB must be a whole number between 128 and 10240 inclusive' ) ) ;
263
+ } ) ;
264
+
265
+ void it ( 'throws on memory above 10240 MB' , ( ) => {
266
+ assert . throws ( ( ) => {
267
+ const app = new App ( ) ;
268
+ const stack = new Stack ( app ) ;
269
+ new ConversationHandlerFunction ( stack , 'conversationHandler' , {
270
+ models : [ ] ,
271
+ memoryMB : 10241 ,
272
+ } ) ;
273
+ } , new Error ( 'memoryMB must be a whole number between 128 and 10240 inclusive' ) ) ;
274
+ } ) ;
275
+
276
+ void it ( 'throws on fractional memory' , ( ) => {
277
+ assert . throws ( ( ) => {
278
+ const app = new App ( ) ;
279
+ const stack = new Stack ( app ) ;
280
+ new ConversationHandlerFunction ( stack , 'conversationHandler' , {
281
+ models : [ ] ,
282
+ memoryMB : 256.2 ,
283
+ } ) ;
284
+ } , new Error ( 'memoryMB must be a whole number between 128 and 10240 inclusive' ) ) ;
285
+ } ) ;
286
+ } ) ;
225
287
} ) ;
0 commit comments