@@ -106,32 +106,6 @@ describe('Class: BedrockAgentFunctionResolver', () => {
106
106
expect ( console . debug ) . toHaveBeenCalled ( ) ;
107
107
} ) ;
108
108
109
- it ( 'accepts custom logger' , async ( ) => {
110
- // Prepare
111
- vi . stubEnv ( 'AWS_LAMBDA_LOG_LEVEL' , 'DEBUG' ) ;
112
-
113
- const logger = {
114
- debug : vi . fn ( ) ,
115
- warn : vi . fn ( ) ,
116
- error : vi . fn ( ) ,
117
- } ;
118
- const app = new BedrockAgentFunctionResolver ( { logger } ) ;
119
-
120
- app . tool ( async ( _params ) => { } , {
121
- name : 'noop' ,
122
- description : 'Does nothing' ,
123
- } ) ;
124
-
125
- // Act
126
-
127
- await app . resolve ( createEvent ( 'noop' , [ ] ) , context ) ;
128
-
129
- // Assess
130
- expect ( logger . debug ) . toHaveBeenCalled ( ) ;
131
- expect ( logger . debug ) . toHaveBeenCalled ( ) ;
132
- expect ( logger . debug ) . toHaveBeenCalled ( ) ;
133
- } ) ;
134
-
135
109
it ( 'only allows five tools to be registered' , async ( ) => {
136
110
// Prepare
137
111
const app = new BedrockAgentFunctionResolver ( ) ;
@@ -229,6 +203,48 @@ describe('Class: BedrockAgentFunctionResolver', () => {
229
203
) . toEqual ( '20' ) ;
230
204
} ) ;
231
205
206
+ it ( 'accepts custom logger' , async ( ) => {
207
+ // Prepare
208
+ vi . stubEnv ( 'AWS_LAMBDA_LOG_LEVEL' , 'DEBUG' ) ;
209
+
210
+ const logger = {
211
+ debug : vi . fn ( ) ,
212
+ warn : vi . fn ( ) ,
213
+ error : vi . fn ( ) ,
214
+ } ;
215
+ const app = new BedrockAgentFunctionResolver ( { logger } ) ;
216
+
217
+ app . tool ( async ( _params ) => { } , {
218
+ name : 'noop' ,
219
+ description : 'Does nothing' ,
220
+ } ) ;
221
+
222
+ app . tool ( async ( _params ) => { } , {
223
+ name : 'noop' ,
224
+ description : 'Does nothing' ,
225
+ } ) ;
226
+
227
+ app . tool (
228
+ async ( _params ) => {
229
+ throw new Error ( ) ;
230
+ } ,
231
+ {
232
+ name : 'error' ,
233
+ description : 'errors' ,
234
+ }
235
+ ) ;
236
+
237
+ // Act
238
+
239
+ await app . resolve ( createEvent ( 'noop' ) , context ) ;
240
+ await app . resolve ( createEvent ( 'error' ) , context ) . catch ( ( ) => { } ) ;
241
+
242
+ // Assess
243
+ expect ( logger . warn ) . toHaveBeenCalled ( ) ;
244
+ expect ( logger . error ) . toHaveBeenCalled ( ) ;
245
+ expect ( logger . debug ) . toHaveBeenCalled ( ) ;
246
+ } ) ;
247
+
232
248
it ( 'tool function has access to the event variable' , async ( ) => {
233
249
// Prepare
234
250
const app = new BedrockAgentFunctionResolver ( ) ;
0 commit comments