diff options
author | Florian Klink <flokli@flokli.de> | 2023-02-27T07·59+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-03-10T10·58+0000 |
commit | 28a862976bd43912e0e5dc16e8919590c36f4cf0 (patch) | |
tree | f6e6fb7eac5145c9519ff8399a14ab1733a75c66 /tvix/store/src/tests | |
parent | 0baaabc43e3027b1676874c536d5ade27abe14b8 (diff) |
refactor(tvix/store/tests): move gen_*_service() into helper r/5928
This allows hiding to tests what exact implementation we're using, when testing things that do something with a store, but don't care what's used for underlying storage. Change-Id: I7cdf60fd73c25d5050159cb31ec177db2bc2a7f1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8155 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/store/src/tests')
-rw-r--r-- | tvix/store/src/tests/mod.rs | 1 | ||||
-rw-r--r-- | tvix/store/src/tests/nar_renderer.rs | 17 | ||||
-rw-r--r-- | tvix/store/src/tests/utils.rs | 24 |
3 files changed, 26 insertions, 16 deletions
diff --git a/tvix/store/src/tests/mod.rs b/tvix/store/src/tests/mod.rs index 735b0789f80d..421858c03083 100644 --- a/tvix/store/src/tests/mod.rs +++ b/tvix/store/src/tests/mod.rs @@ -1 +1,2 @@ mod nar_renderer; +pub mod utils; diff --git a/tvix/store/src/tests/nar_renderer.rs b/tvix/store/src/tests/nar_renderer.rs index 7271a45f597d..4a72be5910fd 100644 --- a/tvix/store/src/tests/nar_renderer.rs +++ b/tvix/store/src/tests/nar_renderer.rs @@ -1,16 +1,13 @@ use crate::blobservice::BlobService; -use crate::blobservice::SledBlobService; use crate::chunkservice::ChunkService; -use crate::chunkservice::SledChunkService; use crate::directoryservice::DirectoryService; -use crate::directoryservice::SledDirectoryService; use crate::nar::NARRenderer; use crate::proto; use crate::proto::DirectoryNode; use crate::proto::FileNode; use crate::proto::SymlinkNode; +use crate::tests::utils::*; use lazy_static::lazy_static; -use std::path::Path; use tempfile::TempDir; const HELLOWORLD_BLOB_CONTENTS: &[u8] = b"Hello World!"; @@ -49,18 +46,6 @@ lazy_static! { }; } -fn gen_blob_service(p: &Path) -> impl BlobService { - SledBlobService::new(p.join("blobs")).unwrap() -} - -fn gen_chunk_service(p: &Path) -> impl ChunkService + Clone { - SledChunkService::new(p.join("chunks")).unwrap() -} - -fn gen_directory_service(p: &Path) -> impl DirectoryService { - SledDirectoryService::new(p.join("directories")).unwrap() -} - #[test] fn single_symlink() { let tmpdir = TempDir::new().unwrap(); diff --git a/tvix/store/src/tests/utils.rs b/tvix/store/src/tests/utils.rs new file mode 100644 index 000000000000..4ddd4102fb97 --- /dev/null +++ b/tvix/store/src/tests/utils.rs @@ -0,0 +1,24 @@ +use std::path::Path; + +use crate::{ + blobservice::{BlobService, SledBlobService}, + chunkservice::{ChunkService, SledChunkService}, + directoryservice::{DirectoryService, SledDirectoryService}, + pathinfoservice::{PathInfoService, SledPathInfoService}, +}; + +pub fn gen_blob_service(p: &Path) -> impl BlobService + Send + Sync + Clone + 'static { + SledBlobService::new(p.join("blobs")).unwrap() +} + +pub fn gen_chunk_service(p: &Path) -> impl ChunkService + Clone { + SledChunkService::new(p.join("chunks")).unwrap() +} + +pub fn gen_directory_service(p: &Path) -> impl DirectoryService + Send + Sync + Clone + 'static { + SledDirectoryService::new(p.join("directories")).unwrap() +} + +pub fn gen_pathinfo_service(p: &Path) -> impl PathInfoService { + SledPathInfoService::new(p.join("pathinfo")).unwrap() +} |