From 07a51c7dc9dd37205368eb0653e23e33cc04406f Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 27 Mar 2024 12:11:39 +0100 Subject: feat(tvix/store): add rstest-based PathInfoService tests This introduces rstest-based tests. We also add fixtures for creating some BlobService / DirectoryService out of thin air. To test a PathInfoService, we don't really care too much about its internal storage - ensuring they work is up to the castore tests. Change-Id: Ia62af076ef9c9fbfcf8b020a781454ad299d972e Reviewed-on: https://cl.tvl.fyi/c/depot/+/11272 Tested-by: BuildkiteCI Reviewed-by: Connor Brewster --- tvix/store/src/tests/fixtures.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'tvix/store/src/tests') diff --git a/tvix/store/src/tests/fixtures.rs b/tvix/store/src/tests/fixtures.rs index 233f98591528..500ac0aa5bc2 100644 --- a/tvix/store/src/tests/fixtures.rs +++ b/tvix/store/src/tests/fixtures.rs @@ -1,8 +1,17 @@ use lazy_static::lazy_static; +use rstest::*; +use std::sync::Arc; pub use tvix_castore::fixtures::*; -use tvix_castore::proto as castorepb; +use tvix_castore::{ + blobservice::{BlobService, MemoryBlobService}, + directoryservice::{DirectoryService, MemoryDirectoryService}, + proto as castorepb, +}; -use crate::proto::{nar_info::ca, nar_info::Ca, NarInfo, PathInfo}; +use crate::proto::{ + nar_info::{ca, Ca}, + NarInfo, PathInfo, +}; pub const DUMMY_NAME: &str = "00000000000000000000000000000000-dummy"; pub const DUMMY_OUTPUT_HASH: [u8; 20] = [0; 20]; @@ -121,3 +130,13 @@ lazy_static! { ..PATH_INFO_WITHOUT_NARINFO.clone() }; } + +#[fixture] +pub(crate) fn blob_service() -> Arc { + Arc::from(MemoryBlobService::default()) +} + +#[fixture] +pub(crate) fn directory_service() -> Arc { + Arc::from(MemoryDirectoryService::default()) +} -- cgit 1.4.1