Skip to content

Commit 43b4f0f

Browse files
mr-czaidoon1
authored andcommitted
tests: use tempfile instead of the current working directory
1 parent fb6cfb9 commit 43b4f0f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/test_comparator.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ type CompareFn = dyn Fn(&[u8], &[u8]) -> Ordering;
1616
pub fn write_to_db_with_comparator(compare_fn: Box<CompareFn>) -> Vec<String> {
1717
let mut result_vec = Vec::new();
1818

19-
let path = "_path_for_rocksdb_storage";
19+
let tempdir = tempfile::Builder::new()
20+
.prefix("_path_for_rocksdb_storage")
21+
.tempdir()
22+
.expect("Failed to create temporary path for the _path_for_rocksdb_storage");
23+
let path = tempdir.path();
2024
{
2125
let mut db_opts = Options::default();
2226

tests/test_merge_operator.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ fn make_merge_max_with_limit(limit: u64) -> impl MergeFn + Clone {
296296
#[test]
297297
fn test_merge_state() {
298298
use {Options, DB};
299-
let path = "_rust_rocksdb_merge_test_state";
299+
let tempdir = tempfile::Builder::new()
300+
.prefix("_rust_rocksdb_merge_test_state")
301+
.tempdir()
302+
.expect("Failed to create temporary path for the _rust_rocksdb_merge_test_state.");
303+
let path = tempdir.path();
300304
let mut opts = Options::default();
301305
opts.create_if_missing(true);
302306
opts.set_merge_operator_associative("max-limit-12", make_merge_max_with_limit(12));

0 commit comments

Comments
 (0)