@@ -16,6 +16,7 @@ import { customEntryHandler } from './test-assets/with-custom-entry/resource.js'
16
16
import { Template } from 'aws-cdk-lib/assertions' ;
17
17
import { defineConversationHandlerFunction } from './factory.js' ;
18
18
import { ConversationHandlerFunction } from '@aws-amplify/ai-constructs/conversation' ;
19
+ import { AmplifyError } from '@aws-amplify/platform-core' ;
19
20
20
21
const createStackAndSetContext = ( ) : Stack => {
21
22
const app = new App ( ) ;
@@ -204,6 +205,55 @@ void describe('ConversationHandlerFactory', () => {
204
205
} ) ;
205
206
} ) ;
206
207
208
+ void it ( 'maps invalid memory error' , ( ) => {
209
+ const factory = defineConversationHandlerFunction ( {
210
+ entry : './test-assets/with-default-entry/handler.ts' ,
211
+ name : 'testHandlerName' ,
212
+ models : [ ] ,
213
+ memoryMB : - 1 ,
214
+ } ) ;
215
+ assert . throws (
216
+ ( ) => factory . getInstance ( getInstanceProps ) ,
217
+ ( error : Error ) => {
218
+ assert . ok ( AmplifyError . isAmplifyError ( error ) ) ;
219
+ assert . strictEqual ( error . name , 'InvalidMemoryMBError' ) ;
220
+ return true ;
221
+ }
222
+ ) ;
223
+ } ) ;
224
+
225
+ void it ( 'passes timeout setting to construct' , ( ) => {
226
+ const factory = defineConversationHandlerFunction ( {
227
+ entry : './test-assets/with-default-entry/handler.ts' ,
228
+ name : 'testHandlerName' ,
229
+ models : [ ] ,
230
+ timeoutSeconds : 124 ,
231
+ } ) ;
232
+ const lambda = factory . getInstance ( getInstanceProps ) ;
233
+ const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
234
+ template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
235
+ template . hasResourceProperties ( 'AWS::Lambda::Function' , {
236
+ Timeout : 124 ,
237
+ } ) ;
238
+ } ) ;
239
+
240
+ void it ( 'maps invalid timeout error' , ( ) => {
241
+ const factory = defineConversationHandlerFunction ( {
242
+ entry : './test-assets/with-default-entry/handler.ts' ,
243
+ name : 'testHandlerName' ,
244
+ models : [ ] ,
245
+ timeoutSeconds : - 1 ,
246
+ } ) ;
247
+ assert . throws (
248
+ ( ) => factory . getInstance ( getInstanceProps ) ,
249
+ ( error : Error ) => {
250
+ assert . ok ( AmplifyError . isAmplifyError ( error ) ) ;
251
+ assert . strictEqual ( error . name , 'InvalidTimeoutError' ) ;
252
+ return true ;
253
+ }
254
+ ) ;
255
+ } ) ;
256
+
207
257
void it ( 'passes log level to construct' , ( ) => {
208
258
const factory = defineConversationHandlerFunction ( {
209
259
entry : './test-assets/with-default-entry/handler.ts' ,
0 commit comments