Skip to content

Commit afe4d36

Browse files
committed
added graph tests to filestore backend
fixed a bug in fs backend
1 parent 8eba7a8 commit afe4d36

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/backend_filestore/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ anyhow = "1.0"
2424

2525
[dev-dependencies]
2626
pretty_assertions = "1"
27+
gravitydb-test-utils = { path = "../gravitydb-test-utils" }

crates/backend_filestore/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ fn list_files(dir: &VfsPath) -> VfsResult<Vec<Vec<u8>>> {
136136
if path.is_dir()? {
137137
result.append(&mut list_files(&path)?);
138138
} else {
139-
result.push(path.as_str().as_bytes().to_vec());
139+
let path = path.as_str();
140+
let path = match path.strip_prefix("/") {
141+
Some(path) => path,
142+
None => path,
143+
};
144+
result.push(path.as_bytes().to_vec());
140145
}
141146
}
142147
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use gravitydb_filestore::{FsKvStore, FileStoreError};
2+
3+
#[test]
4+
fn trivial_queries() -> Result<(), Error> {
5+
let kv = FsKvStore::from_memory().expect("Could not create kv store");
6+
gravitydb_test_utils::trivial_queries(kv)
7+
}
8+
9+
#[test]
10+
fn alexander_ingredients() -> Result<(), Error> {
11+
let kv = FsKvStore::from_memory().expect("Could not create kv store");
12+
gravitydb_test_utils::alexander_ingredients(kv)
13+
}
14+
15+
#[test]
16+
fn which_cocktails_include_gin() -> Result<(), Error> {
17+
let kv = FsKvStore::from_memory().expect("Could not create kv store");
18+
gravitydb_test_utils::which_cocktails_include_gin(kv)
19+
}
20+
21+
#[test]
22+
fn cocktail_statistic() -> Result<(), Error> {
23+
let kv = FsKvStore::from_memory().expect("Could not create kv store");
24+
gravitydb_test_utils::cocktail_statistic(kv)
25+
}
26+
27+
type Error = gravitydb::kv_graph_store::Error<FileStoreError>;
28+

docs/backends_filestore.adoc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,12 @@ fn list_files(dir: &VfsPath) -> VfsResult<Vec<Vec<u8>>> {
225225
if path.is_dir()? {
226226
result.append(&mut list_files(&path)?);
227227
} else {
228-
result.push(path.as_str().as_bytes().to_vec());
228+
let path = path.as_str();
229+
let path = match path.strip_prefix("/") {
230+
Some(path) => path,
231+
None => path,
232+
};
233+
result.push(path.as_bytes().to_vec());
229234
}
230235
}
231236
}

0 commit comments

Comments
 (0)