about summary refs log tree commit diff
path: root/tvix/castore/src/tests/import.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-12-31T21·33+0200
committerflokli <flokli@flokli.de>2024-01-01T14·45+0000
commit597a6b6205c3455ac92d816ad5e85af9615f6063 (patch)
treef9becbc2625eeadd9ac7029f4823dec6b9fb0ddf /tvix/castore/src/tests/import.rs
parent09a92b78d27dbf25210169a35c30bcff0b01b2ec (diff)
refactor(tvix/castore/tests): let gen_*_service return Boxes r/7307
Only convert to and reuse an Arc<…> where needed.

Change-Id: I2c1bc69cca5a4a3ebd3bdb33d6e28e1f5fb86cb9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10514
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/castore/src/tests/import.rs')
-rw-r--r--tvix/castore/src/tests/import.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/tvix/castore/src/tests/import.rs b/tvix/castore/src/tests/import.rs
index 2a2e8ae00acf..75c632799cd9 100644
--- a/tvix/castore/src/tests/import.rs
+++ b/tvix/castore/src/tests/import.rs
@@ -1,7 +1,10 @@
+use crate::blobservice::BlobService;
+use crate::directoryservice::DirectoryService;
 use crate::fixtures::*;
 use crate::import::ingest_path;
 use crate::proto;
 use crate::utils::{gen_blob_service, gen_directory_service};
+use std::sync::Arc;
 use tempfile::TempDir;
 
 #[cfg(target_family = "unix")]
@@ -10,6 +13,9 @@ use std::os::unix::ffi::OsStrExt;
 #[cfg(target_family = "unix")]
 #[tokio::test]
 async fn symlink() {
+    let blob_service: Arc<dyn BlobService> = gen_blob_service().into();
+    let directory_service: Arc<dyn DirectoryService> = gen_directory_service().into();
+
     let tmpdir = TempDir::new().unwrap();
 
     std::fs::create_dir_all(&tmpdir).unwrap();
@@ -20,8 +26,8 @@ async fn symlink() {
     .unwrap();
 
     let root_node = ingest_path(
-        gen_blob_service(),
-        gen_directory_service(),
+        blob_service,
+        directory_service,
         tmpdir.path().join("doesntmatter"),
     )
     .await
@@ -38,15 +44,16 @@ async fn symlink() {
 
 #[tokio::test]
 async fn single_file() {
+    let blob_service: Arc<dyn BlobService> = gen_blob_service().into();
+    let directory_service: Arc<dyn DirectoryService> = gen_directory_service().into();
+
     let tmpdir = TempDir::new().unwrap();
 
     std::fs::write(tmpdir.path().join("root"), HELLOWORLD_BLOB_CONTENTS).unwrap();
 
-    let blob_service = gen_blob_service();
-
     let root_node = ingest_path(
         blob_service.clone(),
-        gen_directory_service(),
+        directory_service,
         tmpdir.path().join("root"),
     )
     .await
@@ -69,6 +76,9 @@ async fn single_file() {
 #[cfg(target_family = "unix")]
 #[tokio::test]
 async fn complicated() {
+    let blob_service: Arc<dyn BlobService> = gen_blob_service().into();
+    let directory_service: Arc<dyn DirectoryService> = gen_directory_service().into();
+
     let tmpdir = TempDir::new().unwrap();
 
     // File ``.keep`
@@ -80,9 +90,6 @@ async fn complicated() {
     // File ``keep/.keep`
     std::fs::write(tmpdir.path().join("keep").join(".keep"), vec![]).unwrap();
 
-    let blob_service = gen_blob_service();
-    let directory_service = gen_directory_service();
-
     let root_node = ingest_path(
         blob_service.clone(),
         directory_service.clone(),