@@ -249,6 +249,7 @@ describe('userTableServerTool.create_from_file', () => {
249249 mockDownloadWorkspaceFile . mockResolvedValue ( Buffer . from ( 'name,age\nAlice,30\nBob,40' ) )
250250 mockGetWorkspaceTableLimits . mockResolvedValue ( { maxRowsPerTable : 1000 , maxTables : 3 } )
251251 mockCreateTable . mockResolvedValue ( buildTable ( { id : 'tbl_new' , name : 'people' } ) )
252+ mockDeleteTable . mockResolvedValue ( undefined )
252253 mockBatchInsertRows . mockImplementation ( async ( data : { rows : unknown [ ] } ) =>
253254 data . rows . map ( ( _ , i ) => ( { id : `row_${ i } ` } ) )
254255 )
@@ -286,8 +287,8 @@ describe('userTableServerTool.create_from_file', () => {
286287 expect ( mockDeleteTable ) . not . toHaveBeenCalled ( )
287288 } )
288289
289- it ( 'deletes the created table when row insertion fails' , async ( ) => {
290- mockBatchInsertRows . mockRejectedValueOnce ( new Error ( 'Maximum row limit (1000) reached ' ) )
290+ it ( 'rolls back the created table and reports the reason when row insertion fails' , async ( ) => {
291+ mockBatchInsertRows . mockRejectedValueOnce ( new Error ( 'Row 2: Column "email" must be unique ' ) )
291292
292293 const result = await userTableServerTool . execute (
293294 { operation : 'create_from_file' , args : { fileId : 'file-1' } } ,
@@ -296,6 +297,8 @@ describe('userTableServerTool.create_from_file', () => {
296297
297298 expect ( result . success ) . toBe ( false )
298299 expect ( mockDeleteTable ) . toHaveBeenCalledWith ( 'tbl_new' , expect . any ( String ) )
300+ expect ( result . message ) . toMatch ( / r o l l e d b a c k / i)
301+ expect ( result . message ) . toMatch ( / m u s t b e u n i q u e / i)
299302 } )
300303} )
301304
0 commit comments