about summary refs log tree commit diff
path: root/tvix/store/src/tests/nar_renderer.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-03-01T17·55+0100
committerflokli <flokli@flokli.de>2023-03-10T10·58+0000
commita4f6c4181aa7f975b1c3aad8d3fb30021388e014 (patch)
treeee2f0a3911503ccb66f29d5b47dbdd763c02b026 /tvix/store/src/tests/nar_renderer.rs
parent535e1b15ab457c9015baebf14bd7b50a38edadb4 (diff)
feat(tvix/store): add new_temporary for all Sled services r/5934
This provides a service using /dev/shm, that's deleted once the
reference is dropped.

Refactor all tests to use these, which allows getting rid of most
TempDir usage in the tests.

The only place where we still use TempDir is in the importer tests,
which work on a filesystem path.

Change-Id: I08a950aa774bf9b46d9f5c92edf5efba36053242
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8193
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/tests/nar_renderer.rs')
-rw-r--r--tvix/store/src/tests/nar_renderer.rs51
1 files changed, 15 insertions, 36 deletions
diff --git a/tvix/store/src/tests/nar_renderer.rs b/tvix/store/src/tests/nar_renderer.rs
index 8c0f738b5143..2b5b4f705c64 100644
--- a/tvix/store/src/tests/nar_renderer.rs
+++ b/tvix/store/src/tests/nar_renderer.rs
@@ -8,15 +8,13 @@ use crate::proto::FileNode;
 use crate::proto::SymlinkNode;
 use crate::tests::fixtures::*;
 use crate::tests::utils::*;
-use tempfile::TempDir;
 
 #[test]
 fn single_symlink() {
-    let tmpdir = TempDir::new().unwrap();
     let renderer = NARRenderer::new(
-        gen_blob_service(tmpdir.path()),
-        gen_chunk_service(tmpdir.path()),
-        gen_directory_service(tmpdir.path()),
+        gen_blob_service(),
+        gen_chunk_service(),
+        gen_directory_service(),
     );
     // don't put anything in the stores, as we don't actually do any requests.
 
@@ -39,15 +37,10 @@ fn single_symlink() {
 /// match what's in the store.
 #[test]
 fn single_file_missing_blob() {
-    let tmpdir = TempDir::new().unwrap();
-
-    let blob_service = gen_blob_service(tmpdir.path());
-    let chunk_service = gen_chunk_service(tmpdir.path());
-
     let renderer = NARRenderer::new(
-        blob_service,
-        chunk_service,
-        gen_directory_service(tmpdir.path()),
+        gen_blob_service(),
+        gen_chunk_service(),
+        gen_directory_service(),
     );
     let mut buf: Vec<u8> = vec![];
 
@@ -74,10 +67,8 @@ fn single_file_missing_blob() {
 /// than specified in the proto node.
 #[test]
 fn single_file_wrong_blob_size() {
-    let tmpdir = TempDir::new().unwrap();
-
-    let blob_service = gen_blob_service(tmpdir.path());
-    let chunk_service = gen_chunk_service(tmpdir.path());
+    let blob_service = gen_blob_service();
+    let chunk_service = gen_chunk_service();
 
     // insert blob and chunk into the stores
     chunk_service
@@ -97,11 +88,7 @@ fn single_file_wrong_blob_size() {
         )
         .unwrap();
 
-    let renderer = NARRenderer::new(
-        blob_service,
-        chunk_service,
-        gen_directory_service(tmpdir.path()),
-    );
+    let renderer = NARRenderer::new(blob_service, chunk_service, gen_directory_service());
     let mut buf: Vec<u8> = vec![];
 
     let e = renderer
@@ -138,10 +125,8 @@ fn single_file_wrong_blob_size() {
 
 #[test]
 fn single_file() {
-    let tmpdir = TempDir::new().unwrap();
-
-    let blob_service = gen_blob_service(tmpdir.path());
-    let chunk_service = gen_chunk_service(tmpdir.path());
+    let blob_service = gen_blob_service();
+    let chunk_service = gen_chunk_service();
 
     chunk_service
         .put(HELLOWORLD_BLOB_CONTENTS.to_vec())
@@ -160,11 +145,7 @@ fn single_file() {
         )
         .unwrap();
 
-    let renderer = NARRenderer::new(
-        blob_service,
-        chunk_service,
-        gen_directory_service(tmpdir.path()),
-    );
+    let renderer = NARRenderer::new(blob_service, chunk_service, gen_directory_service());
     let mut buf: Vec<u8> = vec![];
 
     renderer
@@ -184,11 +165,9 @@ fn single_file() {
 
 #[test]
 fn test_complicated() {
-    let tmpdir = TempDir::new().unwrap();
-
-    let blob_service = gen_blob_service(tmpdir.path());
-    let chunk_service = gen_chunk_service(tmpdir.path());
-    let directory_service = gen_directory_service(tmpdir.path());
+    let blob_service = gen_blob_service();
+    let chunk_service = gen_chunk_service();
+    let directory_service = gen_directory_service();
 
     // put all data into the stores.
     let digest = chunk_service.put(EMPTY_BLOB_CONTENTS.to_vec()).unwrap();