Skip to content

Commit 8724503

Browse files
committed
Update test case
1 parent e27e833 commit 8724503

File tree

8 files changed

+75
-78
lines changed

8 files changed

+75
-78
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Cargo.lock

+52-51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,5 @@ path-absolutize = "3.0.14"
4545
[dev-dependencies]
4646
tokio = { version = "1.21.2", features = ["macros", "rt"] }
4747

48-
4948
[lib]
5049
name = "db"

db/src/constant/cf.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,10 @@ use lazy_static::lazy_static;
55
#[derive(Hash, PartialEq, Eq)]
66
pub enum ColumnFamily {
77
TestSuite,
8-
Edge,
9-
VertexProperty,
10-
Property,
11-
Vertex,
128
}
139

1410
lazy_static! {
15-
pub static ref COLUMN_FAMILIES: HashMap<ColumnFamily, String> = HashMap::from([
16-
(ColumnFamily::TestSuite, "test_suite:v1".to_string()),
17-
(ColumnFamily::Edge, "edges:v1".to_string()),
18-
(ColumnFamily::VertexProperty, "vertex-properties:v1".to_string()),
19-
(ColumnFamily::Property, "properties:v1".to_string()),
20-
(ColumnFamily::Vertex, "vertices:v1".to_string())
21-
]);
11+
pub static ref COLUMN_FAMILIES: HashMap<ColumnFamily, String> =
12+
HashMap::from([(ColumnFamily::TestSuite, "test_suite:v1".to_string()),]);
2213
pub static ref CF_NAMES: Vec<&'static String> = COLUMN_FAMILIES.values().collect();
2314
}

db/src/storage/ds.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ mod test {
119119

120120
#[tokio::test]
121121
async fn should_create() {
122-
let db = Datastore::new("redb:../temp/v1.redb");
122+
let db = Datastore::new("redb:../temp/redb");
123123
assert!(db.transaction(false).await.is_ok());
124124

125125
let key1 = i32::to_be_bytes(2001);
@@ -134,6 +134,8 @@ mod test {
134134
tx.set(key1, val1, tag!()).await.unwrap();
135135
tx.set(key2, val2, tag!()).await.unwrap();
136136
tx.set(key3, val3, tag!()).await.unwrap();
137+
let iter = tx.iterate(tag!()).await.unwrap();
138+
assert!(iter.len() == 3);
137139
tx.commit().await.unwrap();
138140
}
139141

@@ -157,6 +159,8 @@ mod test {
157159
tx.set(key1, val1, tags.clone()).await.unwrap();
158160
tx.set(key2, val2, tags.clone()).await.unwrap();
159161
tx.set(key3, val3, tags.clone()).await.unwrap();
162+
let iter = tx.iterate(tags.clone()).await.unwrap();
163+
assert!(iter.len() == 3);
160164
tx.commit().await.unwrap();
161165
}
162166
}

db/src/storage/kvs/redb/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ pub use tx::*;
77
pub use ty::*;
88

99
use crate::{
10-
util::generate_path, DBTransaction, DatastoreAdapter, Error, StorageAdapter,
11-
StorageAdapterName, StorageVariant,
10+
util::{generate_path, get_absolute_path},
11+
DBTransaction, DatastoreAdapter, Error, StorageAdapter, StorageAdapterName, StorageVariant,
1212
};
1313
pub struct ReDBAdapter(StorageAdapter<DBType>);
1414

@@ -20,7 +20,8 @@ impl ReDBAdapter {
2020

2121
pub fn new(path: &str) -> Result<ReDBAdapter, Error> {
2222
let path = &path["redb:".len()..];
23-
let db_instance = unsafe { Database::create(path).unwrap() };
23+
let abs_path = get_absolute_path(path);
24+
let db_instance = unsafe { Database::create(abs_path.as_str()).unwrap() };
2425

2526
Ok(ReDBAdapter(StorageAdapter::<DBType>::new(
2627
StorageAdapterName::ReDB,

gui/config-example.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"databases": [
33
{
44
"name": "rocksdb",
5-
"path": "../temp"
5+
"path": "../temp/cf"
66
},
77
{
88
"name": "redb",

0 commit comments

Comments
 (0)