@@ -217,7 +217,7 @@ describe("LibSQLVectorStore", () => {
217217 expect ( results [ 0 ] . id ) . toBe ( "test-path-segments" )
218218 expect ( results [ 0 ] . payload ! . filePath ) . toBe ( filePath )
219219
220- const resultsExact = await vectorStore . search ( [ 0.1 , 0.2 , 0.3 ] , filePath )
220+ const resultsExact = await vectorStore . search ( [ 0.1 , 0.2 , 0.3 ] , path . dirname ( filePath ) )
221221 expect ( resultsExact ) . toHaveLength ( 1 )
222222 expect ( resultsExact [ 0 ] . id ) . toBe ( "test-path-segments" )
223223 } )
@@ -506,16 +506,16 @@ describe("LibSQLVectorStore", () => {
506506 } )
507507
508508 it ( "should throw when deletePointsByMultipleFilePaths fails" , async ( ) => {
509- const mockTransaction = vi . spyOn ( vectorStore [ "client" ] , "transaction" ) . mockImplementation ( ( ) => {
510- throw new Error ( "Simulated database transaction failure during delete ")
511- } )
509+ const mockExecute = vi
510+ . spyOn ( vectorStore [ "client" ] , "execute ")
511+ . mockRejectedValue ( new Error ( "Simulated database transaction failure during delete" ) )
512512
513513 await expect ( vectorStore . deletePointsByMultipleFilePaths ( [ "test/file1.ts" ] ) ) . rejects . toThrow (
514514 "Simulated database transaction failure during delete" ,
515515 )
516- expect ( mockTransaction ) . toHaveBeenCalled ( )
516+ expect ( mockExecute ) . toHaveBeenCalled ( )
517517
518- mockTransaction . mockRestore ( )
518+ mockExecute . mockRestore ( )
519519 } )
520520
521521 it ( "should throw when collectionExists fails" , async ( ) => {
@@ -536,18 +536,14 @@ describe("LibSQLVectorStore", () => {
536536 ; ( vectorStore as any ) . maxRetries = 3
537537
538538 let callCount = 0
539- const mockTransaction = vi . spyOn ( vectorStore [ "client" ] , "transaction " ) . mockImplementation ( async ( ) => {
539+ const mockBatch = vi . spyOn ( vectorStore [ "client" ] , "batch " ) . mockImplementation ( async ( ) => {
540540 callCount ++
541541 if ( callCount <= ( vectorStore as any ) . maxRetries ) {
542542 const error : any = new Error ( "database is locked" )
543543 error . code = "SQLITE_BUSY"
544544 throw error
545545 }
546- return {
547- execute : vi . fn ( ) ,
548- commit : vi . fn ( ) ,
549- rollback : vi . fn ( ) ,
550- } as any
546+ return [ ] as any // batch returns an array of results
551547 } )
552548
553549 const points = [
@@ -564,9 +560,9 @@ describe("LibSQLVectorStore", () => {
564560 ]
565561
566562 await expect ( vectorStore . upsertPoints ( points ) ) . rejects . toThrow ( "database is locked" )
567- expect ( mockTransaction ) . toHaveBeenCalledTimes ( ( vectorStore as any ) . maxRetries )
563+ expect ( mockBatch ) . toHaveBeenCalledTimes ( ( vectorStore as any ) . maxRetries )
568564
569- mockTransaction . mockRestore ( )
565+ mockBatch . mockRestore ( )
570566 ; ( vectorStore as any ) . maxRetries = originalMaxRetries
571567 } , 10000 )
572568 } )
0 commit comments