Skip to content

Commit ede10cd

Browse files
committed
test: use unique test db path helpers in vector storage tests
1 parent dfd841f commit ede10cd

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/storage/tests/redis_vector_test.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,11 @@ fn test_vsim_rejects_query_dimension_mismatch() {
377377

378378
#[tokio::test]
379379
async fn test_storage_routes_all_members_of_one_vectorset_to_one_instance() {
380-
let temp = tempfile::tempdir().expect("temp dir");
380+
let test_db_path = unique_test_db_path();
381+
safe_cleanup_test_db(&test_db_path);
381382
let mut storage = Storage::new(3, 0);
382383
let _receiver = storage
383-
.open(Arc::new(StorageOptions::default()), temp.path())
384+
.open(Arc::new(StorageOptions::default()), &test_db_path)
384385
.expect("open storage");
385386
let key = b"routed-vectors";
386387
let x = CanonicalVector::from_values(&[1.0, 0.0]).expect("x");
@@ -429,6 +430,7 @@ async fn test_storage_routes_all_members_of_one_vectorset_to_one_instance() {
429430
}
430431

431432
storage.shutdown().await;
433+
safe_cleanup_test_db(&test_db_path);
432434
}
433435

434436
#[test]
@@ -445,10 +447,11 @@ fn test_type_returns_vectorset() {
445447

446448
#[tokio::test]
447449
async fn test_expired_vectorset_reads_as_missing() {
448-
let temp = tempfile::tempdir().expect("temp dir");
450+
let test_db_path = unique_test_db_path();
451+
safe_cleanup_test_db(&test_db_path);
449452
let mut storage = Storage::new(1, 0);
450453
let _receiver = storage
451-
.open(Arc::new(StorageOptions::default()), temp.path())
454+
.open(Arc::new(StorageOptions::default()), &test_db_path)
452455
.expect("open storage");
453456
let key = b"expiring-vectors";
454457
let vector = CanonicalVector::from_values(&[1.0, 0.0]).expect("vector");
@@ -474,6 +477,7 @@ async fn test_expired_vectorset_reads_as_missing() {
474477
assert_eq!(storage.key_type(key).expect("expired type"), "none");
475478

476479
storage.shutdown().await;
480+
safe_cleanup_test_db(&test_db_path);
477481
}
478482

479483
#[test]
@@ -505,10 +509,11 @@ fn test_flushdb_removes_vector_meta_and_members() {
505509

506510
#[tokio::test]
507511
async fn test_vector_storage_rejects_cluster_mode() {
508-
let temp = tempfile::tempdir().expect("temp dir");
512+
let test_db_path = unique_test_db_path();
513+
safe_cleanup_test_db(&test_db_path);
509514
let mut storage = Storage::new(1, 0);
510515
let _receiver = storage
511-
.open(Arc::new(StorageOptions::default()), temp.path())
516+
.open(Arc::new(StorageOptions::default()), &test_db_path)
512517
.expect("open storage");
513518
storage.set_append_log_fn(Arc::new(|_| panic!("vector API must not append Raft log")));
514519
let vector = CanonicalVector::from_values(&[1.0, 0.0]).expect("vector");
@@ -530,4 +535,5 @@ async fn test_vector_storage_rejects_cluster_mode() {
530535
assert!(storage.vismember(b"vectors", b"member").is_err());
531536

532537
storage.shutdown().await;
538+
safe_cleanup_test_db(&test_db_path);
533539
}

0 commit comments

Comments
 (0)