about summary refs log tree commit diff
path: root/tvix/store/src/proto/tests/pathinfo.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-10-13T16·09+0300
committerflokli <flokli@flokli.de>2024-10-17T22·15+0000
commit1c80bc4b5b2736e9421fc8a6f833f1e592e08642 (patch)
treea4d58eec75f230bbf559933a85d19c25ed35e8b7 /tvix/store/src/proto/tests/pathinfo.rs
parentf0d594789ee01df43de50198adef91a11e2a355a (diff)
refactor(tvix/store): remove use of lazy_static r/8825
This is now supported in the standard library via std::sync::LazyLock,
but requires some manual shuffling around of code.

Change-Id: Ifca792f4d2dbc36b703de4a4dfa406015ab86da7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12614
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: flokli <flokli@flokli.de>
Reviewed-by: edef <edef@edef.eu>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/proto/tests/pathinfo.rs')
-rw-r--r--tvix/store/src/proto/tests/pathinfo.rs48
1 files changed, 25 insertions, 23 deletions
diff --git a/tvix/store/src/proto/tests/pathinfo.rs b/tvix/store/src/proto/tests/pathinfo.rs
index 320f419b6c59..edda64045f8e 100644
--- a/tvix/store/src/proto/tests/pathinfo.rs
+++ b/tvix/store/src/proto/tests/pathinfo.rs
@@ -1,37 +1,39 @@
+use std::sync::LazyLock;
+
 use crate::pathinfoservice::PathInfo;
 use crate::proto::{self, ValidatePathInfoError};
 use crate::tests::fixtures::{DUMMY_PATH, DUMMY_PATH_DIGEST, DUMMY_PATH_STR};
 use bytes::Bytes;
-use lazy_static::lazy_static;
 use nix_compat::store_path;
 use rstest::rstest;
 use tvix_castore::fixtures::DUMMY_DIGEST;
 use tvix_castore::proto as castorepb;
 use tvix_castore::{DirectoryError, ValidateNodeError};
 
-lazy_static! {
-    /// A valid PathInfo message
-    /// The references in `narinfo.reference_names` aligns with what's in
-    /// `references`.
-    static ref PROTO_PATH_INFO : proto::PathInfo = proto::PathInfo {
-        node: Some(castorepb::Node {
-            node: Some(castorepb::node::Node::Directory(castorepb::DirectoryNode {
-                name: DUMMY_PATH_STR.into(),
-                digest: DUMMY_DIGEST.clone().into(),
-                size: 0,
-            })),
-        }),
-        references: vec![DUMMY_PATH_DIGEST.as_slice().into()],
-        narinfo: Some(proto::NarInfo {
-            nar_size: 0,
-            nar_sha256: DUMMY_DIGEST.clone().into(),
-            signatures: vec![],
-            reference_names: vec![DUMMY_PATH_STR.to_string()],
-            deriver: None,
-            ca: Some(proto::nar_info::Ca { r#type: proto::nar_info::ca::Hash::NarSha256.into(), digest:  DUMMY_DIGEST.clone().into() })
+/// A valid PathInfo message
+/// The references in `narinfo.reference_names` aligns with what's in
+/// `references`.
+static PROTO_PATH_INFO: LazyLock<proto::PathInfo> = LazyLock::new(|| proto::PathInfo {
+    node: Some(castorepb::Node {
+        node: Some(castorepb::node::Node::Directory(castorepb::DirectoryNode {
+            name: DUMMY_PATH_STR.into(),
+            digest: DUMMY_DIGEST.clone().into(),
+            size: 0,
+        })),
+    }),
+    references: vec![DUMMY_PATH_DIGEST.as_slice().into()],
+    narinfo: Some(proto::NarInfo {
+        nar_size: 0,
+        nar_sha256: DUMMY_DIGEST.clone().into(),
+        signatures: vec![],
+        reference_names: vec![DUMMY_PATH_STR.to_string()],
+        deriver: None,
+        ca: Some(proto::nar_info::Ca {
+            r#type: proto::nar_info::ca::Hash::NarSha256.into(),
+            digest: DUMMY_DIGEST.clone().into(),
         }),
-    };
-}
+    }),
+});
 
 #[test]
 fn convert_valid() {