@@ -3,7 +3,7 @@ import pg from 'pg';
3
3
import fs from 'fs' ;
4
4
import path from 'path' ;
5
5
import { describe , test , expect , beforeEach , afterEach , vi , beforeAll } from 'vitest' ;
6
- import { DatabaseAdapter , elizaLogger , type Memory , type Content , EmbeddingProvider } from '@elizaos/core' ;
6
+ import { elizaLogger , type Memory , type Content } from '@elizaos/core' ;
7
7
8
8
// Increase test timeout
9
9
vi . setConfig ( { testTimeout : 15000 } ) ;
@@ -41,7 +41,7 @@ vi.mock('@elizaos/core', () => ({
41
41
const parseVectorString = ( vectorStr : string ) : number [ ] => {
42
42
if ( ! vectorStr ) return [ ] ;
43
43
// Remove brackets and split by comma
44
- return vectorStr . replace ( / [ \ [\] ] / g, '' ) . split ( ',' ) . map ( Number ) ;
44
+ return vectorStr . replace ( / [ [ \] ] / g, '' ) . split ( ',' ) . map ( Number ) ;
45
45
} ;
46
46
47
47
describe ( 'PostgresDatabaseAdapter - Vector Extension Validation' , ( ) => {
@@ -111,7 +111,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
111
111
user : 'postgres' ,
112
112
password : 'postgres'
113
113
} ) ;
114
-
114
+
115
115
const setupClient = await setupPool . connect ( ) ;
116
116
try {
117
117
await cleanDatabase ( setupClient ) ;
@@ -133,13 +133,13 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
133
133
user : 'postgres' ,
134
134
password : 'postgres'
135
135
} ) ;
136
-
136
+
137
137
testClient = await testPool . connect ( ) ;
138
138
elizaLogger . debug ( 'Database connection established' ) ;
139
-
139
+
140
140
await cleanDatabase ( testClient ) ;
141
141
elizaLogger . debug ( 'Database cleaned' ) ;
142
-
142
+
143
143
adapter = new PostgresDatabaseAdapter ( {
144
144
host : 'localhost' ,
145
145
port : 5433 ,
@@ -254,7 +254,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
254
254
elizaLogger . debug ( 'Attempting initialization with error...' ) ;
255
255
await expect ( adapter . init ( ) ) . rejects . toThrow ( 'Schema read error' ) ;
256
256
elizaLogger . success ( 'Error thrown as expected' ) ;
257
-
257
+
258
258
// Verify no tables were created
259
259
elizaLogger . debug ( 'Verifying rollback...' ) ;
260
260
const { rows } = await testClient . query ( `
@@ -277,19 +277,19 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
277
277
describe ( 'Memory Operations with Vector' , ( ) => {
278
278
const TEST_UUID = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' ;
279
279
const TEST_TABLE = 'test_memories' ;
280
-
280
+
281
281
beforeEach ( async ( ) => {
282
282
elizaLogger . info ( 'Setting up memory operations test...' ) ;
283
283
try {
284
284
// Ensure clean state and proper initialization
285
285
await adapter . init ( ) ;
286
-
286
+
287
287
// Verify vector extension and search path
288
288
await testClient . query ( `
289
289
SET search_path TO public, extensions;
290
290
SELECT set_config('app.use_openai_embedding', 'true', false);
291
291
` ) ;
292
-
292
+
293
293
// Create necessary account and room first
294
294
await testClient . query ( 'BEGIN' ) ;
295
295
try {
@@ -298,19 +298,19 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
298
298
VALUES ($1, 'test@test.com')
299
299
ON CONFLICT (id) DO NOTHING
300
300
` , [ TEST_UUID ] ) ;
301
-
301
+
302
302
await testClient . query ( `
303
303
INSERT INTO rooms (id)
304
304
VALUES ($1)
305
305
ON CONFLICT (id) DO NOTHING
306
306
` , [ TEST_UUID ] ) ;
307
-
307
+
308
308
await testClient . query ( 'COMMIT' ) ;
309
309
} catch ( error ) {
310
310
await testClient . query ( 'ROLLBACK' ) ;
311
311
throw error ;
312
312
}
313
-
313
+
314
314
} catch ( error ) {
315
315
elizaLogger . error ( 'Memory operations setup failed:' , {
316
316
error : error instanceof Error ? error . message : String ( error )
@@ -324,7 +324,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
324
324
const content : Content = {
325
325
text : 'test content'
326
326
} ;
327
-
327
+
328
328
const memory : Memory = {
329
329
id : TEST_UUID ,
330
330
content,
@@ -383,7 +383,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
383
383
await testClient . query ( 'ROLLBACK' ) ;
384
384
throw error ;
385
385
}
386
-
386
+
387
387
// Act
388
388
const results = await adapter . searchMemoriesByEmbedding ( embedding , {
389
389
tableName : TEST_TABLE ,
@@ -405,7 +405,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
405
405
const content : Content = {
406
406
text : 'test content'
407
407
} ;
408
-
408
+
409
409
const memory : Memory = {
410
410
id : TEST_UUID ,
411
411
content,
@@ -430,4 +430,4 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
430
430
}
431
431
} , { timeout : 30000 } ) ; // Increased timeout for retry attempts
432
432
} ) ;
433
- } ) ;
433
+ } ) ;
0 commit comments