about summary refs log tree commit diff
path: root/tvix/store/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store/src/tests')
-rw-r--r--tvix/store/src/tests/fixtures.rs16
-rw-r--r--tvix/store/src/tests/import.rs17
-rw-r--r--tvix/store/src/tests/nar_renderer.rs16
3 files changed, 24 insertions, 25 deletions
diff --git a/tvix/store/src/tests/fixtures.rs b/tvix/store/src/tests/fixtures.rs
index 934d9e4c5302..a1df729f1c5c 100644
--- a/tvix/store/src/tests/fixtures.rs
+++ b/tvix/store/src/tests/fixtures.rs
@@ -33,7 +33,7 @@ lazy_static! {
     pub static ref DIRECTORY_WITH_KEEP: proto::Directory = proto::Directory {
         directories: vec![],
         files: vec![FileNode {
-            name: ".keep".to_string(),
+            name: b".keep".to_vec(),
             digest: EMPTY_BLOB_DIGEST.to_vec(),
             size: 0,
             executable: false,
@@ -42,25 +42,25 @@ lazy_static! {
     };
     pub static ref DIRECTORY_COMPLICATED: proto::Directory = proto::Directory {
         directories: vec![DirectoryNode {
-            name: "keep".to_string(),
+            name: b"keep".to_vec(),
             digest: DIRECTORY_WITH_KEEP.digest().to_vec(),
             size: DIRECTORY_WITH_KEEP.size(),
         }],
         files: vec![FileNode {
-            name: ".keep".to_string(),
+            name: b".keep".to_vec(),
             digest: EMPTY_BLOB_DIGEST.to_vec(),
             size: 0,
             executable: false,
         }],
         symlinks: vec![SymlinkNode {
-            name: "aa".to_string(),
-            target: "/nix/store/somewhereelse".to_string(),
+            name: b"aa".to_vec(),
+            target: b"/nix/store/somewhereelse".to_vec(),
         }],
     };
     pub static ref DIRECTORY_A: Directory = Directory::default();
     pub static ref DIRECTORY_B: Directory = Directory {
         directories: vec![DirectoryNode {
-            name: "a".to_string(),
+            name: b"a".to_vec(),
             digest: DIRECTORY_A.digest().to_vec(),
             size: DIRECTORY_A.size(),
         }],
@@ -69,12 +69,12 @@ lazy_static! {
     pub static ref DIRECTORY_C: Directory = Directory {
         directories: vec![
             DirectoryNode {
-                name: "a".to_string(),
+                name: b"a".to_vec(),
                 digest: DIRECTORY_A.digest().to_vec(),
                 size: DIRECTORY_A.size(),
             },
             DirectoryNode {
-                name: "a'".to_string(),
+                name: b"a'".to_vec(),
                 digest: DIRECTORY_A.digest().to_vec(),
                 size: DIRECTORY_A.size(),
             }
diff --git a/tvix/store/src/tests/import.rs b/tvix/store/src/tests/import.rs
index ab6557421947..291501f72768 100644
--- a/tvix/store/src/tests/import.rs
+++ b/tvix/store/src/tests/import.rs
@@ -6,6 +6,9 @@ use crate::tests::fixtures::*;
 use tempfile::TempDir;
 
 #[cfg(target_family = "unix")]
+use std::os::unix::ffi::OsStrExt;
+
+#[cfg(target_family = "unix")]
 #[test]
 fn symlink() {
     let tmpdir = TempDir::new().unwrap();
@@ -26,8 +29,8 @@ fn symlink() {
 
     assert_eq!(
         crate::proto::node::Node::Symlink(proto::SymlinkNode {
-            name: "doesntmatter".to_string(),
-            target: "/nix/store/somewhereelse".to_string(),
+            name: "doesntmatter".into(),
+            target: "/nix/store/somewhereelse".into(),
         }),
         root_node,
     )
@@ -50,7 +53,7 @@ fn single_file() {
 
     assert_eq!(
         crate::proto::node::Node::File(proto::FileNode {
-            name: "root".to_string(),
+            name: "root".into(),
             digest: HELLOWORLD_BLOB_DIGEST.to_vec(),
             size: HELLOWORLD_BLOB_CONTENTS.len() as u32,
             executable: false,
@@ -62,6 +65,7 @@ fn single_file() {
     assert!(blob_service.has(&HELLOWORLD_BLOB_DIGEST).unwrap());
 }
 
+#[cfg(target_family = "unix")]
 #[test]
 fn complicated() {
     let tmpdir = TempDir::new().unwrap();
@@ -88,12 +92,7 @@ fn complicated() {
     // ensure root_node matched expectations
     assert_eq!(
         crate::proto::node::Node::Directory(proto::DirectoryNode {
-            name: tmpdir
-                .path()
-                .file_name()
-                .unwrap()
-                .to_string_lossy()
-                .to_string(),
+            name: tmpdir.path().file_name().unwrap().as_bytes().to_vec(),
             digest: DIRECTORY_COMPLICATED.digest().to_vec(),
             size: DIRECTORY_COMPLICATED.size(),
         }),
diff --git a/tvix/store/src/tests/nar_renderer.rs b/tvix/store/src/tests/nar_renderer.rs
index b92fdc087b28..055538376b72 100644
--- a/tvix/store/src/tests/nar_renderer.rs
+++ b/tvix/store/src/tests/nar_renderer.rs
@@ -15,8 +15,8 @@ fn single_symlink() {
     write_nar(
         &mut buf,
         &crate::proto::node::Node::Symlink(SymlinkNode {
-            name: "doesntmatter".to_string(),
-            target: "/nix/store/somewhereelse".to_string(),
+            name: "doesntmatter".into(),
+            target: "/nix/store/somewhereelse".into(),
         }),
         // don't put anything in the stores, as we don't actually do any requests.
         gen_blob_service(),
@@ -35,7 +35,7 @@ fn single_file_missing_blob() {
     let e = write_nar(
         &mut buf,
         &crate::proto::node::Node::File(FileNode {
-            name: "doesntmatter".to_string(),
+            name: "doesntmatter".into(),
             digest: HELLOWORLD_BLOB_DIGEST.to_vec(),
             size: HELLOWORLD_BLOB_CONTENTS.len() as u32,
             executable: false,
@@ -76,7 +76,7 @@ fn single_file_wrong_blob_size() {
         let e = write_nar(
             &mut buf,
             &crate::proto::node::Node::File(FileNode {
-                name: "doesntmatter".to_string(),
+                name: "doesntmatter".into(),
                 digest: HELLOWORLD_BLOB_DIGEST.to_vec(),
                 size: 42, // <- note the wrong size here!
                 executable: false,
@@ -101,7 +101,7 @@ fn single_file_wrong_blob_size() {
         let e = write_nar(
             &mut buf,
             &crate::proto::node::Node::File(FileNode {
-                name: "doesntmatter".to_string(),
+                name: "doesntmatter".into(),
                 digest: HELLOWORLD_BLOB_DIGEST.to_vec(),
                 size: 2, // <- note the wrong size here!
                 executable: false,
@@ -138,7 +138,7 @@ fn single_file() {
     write_nar(
         &mut buf,
         &crate::proto::node::Node::File(FileNode {
-            name: "doesntmatter".to_string(),
+            name: "doesntmatter".into(),
             digest: HELLOWORLD_BLOB_DIGEST.to_vec(),
             size: HELLOWORLD_BLOB_CONTENTS.len() as u32,
             executable: false,
@@ -176,7 +176,7 @@ fn test_complicated() {
     write_nar(
         &mut buf,
         &crate::proto::node::Node::Directory(DirectoryNode {
-            name: "doesntmatter".to_string(),
+            name: "doesntmatter".into(),
             digest: DIRECTORY_COMPLICATED.digest().to_vec(),
             size: DIRECTORY_COMPLICATED.size(),
         }),
@@ -190,7 +190,7 @@ fn test_complicated() {
     // ensure calculate_nar does return the correct sha256 digest and sum.
     let (nar_size, nar_digest) = calculate_size_and_sha256(
         &crate::proto::node::Node::Directory(DirectoryNode {
-            name: "doesntmatter".to_string(),
+            name: "doesntmatter".into(),
             digest: DIRECTORY_COMPLICATED.digest().to_vec(),
             size: DIRECTORY_COMPLICATED.size(),
         }),