From 3cb943460580cffb83b46c0ae3e7957eaf9170ef Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 27 Mar 2024 12:12:47 +0100 Subject: [PATCH] refactor(tvix/store/nar/import): use rstest fixtures from castore This stops using the gen_{blob,directory}_service() functions from tvix_castore::utils in favor of the rstest-based fixtures. Change-Id: I4c2fff2926f34af63d3bd5c29c8e939dbdf7e062 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11274 Reviewed-by: Connor Brewster Tested-by: BuildkiteCI --- tvix/store/src/nar/import.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tvix/store/src/nar/import.rs b/tvix/store/src/nar/import.rs index 20b922a61..6f4dcdea5 100644 --- a/tvix/store/src/nar/import.rs +++ b/tvix/store/src/nar/import.rs @@ -223,6 +223,7 @@ mod test { use std::io::Cursor; use std::sync::Arc; + use rstest::*; use tokio_stream::StreamExt; use tvix_castore::blobservice::BlobService; use tvix_castore::directoryservice::DirectoryService; @@ -231,17 +232,18 @@ mod test { HELLOWORLD_BLOB_DIGEST, }; use tvix_castore::proto as castorepb; - use tvix_castore::utils::{gen_blob_service, gen_directory_service}; use crate::tests::fixtures::{ - NAR_CONTENTS_COMPLICATED, NAR_CONTENTS_HELLOWORLD, NAR_CONTENTS_SYMLINK, + blob_service, directory_service, NAR_CONTENTS_COMPLICATED, NAR_CONTENTS_HELLOWORLD, + NAR_CONTENTS_SYMLINK, }; + #[rstest] #[tokio::test] - async fn single_symlink() { - let blob_service = gen_blob_service(); - let directory_service = gen_directory_service(); - + async fn single_symlink( + blob_service: Arc, + directory_service: Arc, + ) { let handle = tokio::runtime::Handle::current(); let root_node = handle @@ -265,11 +267,12 @@ mod test { ); } + #[rstest] #[tokio::test] - async fn single_file() { - let blob_service: Arc = gen_blob_service().into(); - let directory_service = gen_directory_service(); - + async fn single_file( + blob_service: Arc, + directory_service: Arc, + ) { let handle = tokio::runtime::Handle::current(); let root_node = handle @@ -301,11 +304,12 @@ mod test { assert!(blob_service.has(&HELLOWORLD_BLOB_DIGEST).await.unwrap()); } + #[rstest] #[tokio::test] - async fn complicated() { - let blob_service: Arc = gen_blob_service().into(); - let directory_service: Arc = gen_directory_service().into(); - + async fn complicated( + blob_service: Arc, + directory_service: Arc, + ) { let handle = tokio::runtime::Handle::current(); let root_node = handle