From abfb2298200be91a2b1d0273d52d480de311ddb5 Mon Sep 17 00:00:00 2001 From: marshmallow Date: Fri, 24 Oct 2025 11:14:54 +1100 Subject: [PATCH] add test for force_always_local --- tests/rust/non_trivial_hive/hive.nix | 2 ++ wire/lib/src/hive/mod.rs | 30 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/rust/non_trivial_hive/hive.nix b/tests/rust/non_trivial_hive/hive.nix index 41ab2f7..999fd05 100644 --- a/tests/rust/non_trivial_hive/hive.nix +++ b/tests/rust/non_trivial_hive/hive.nix @@ -35,6 +35,8 @@ makeHive { source = "hi"; }; + deployment.buildOnTarget = true; + nixpkgs.hostPlatform = "x86_64-linux"; }; } diff --git a/wire/lib/src/hive/mod.rs b/wire/lib/src/hive/mod.rs index 6f80e8f..2c330db 100644 --- a/wire/lib/src/hive/mod.rs +++ b/wire/lib/src/hive/mod.rs @@ -195,6 +195,7 @@ mod tests { upload_at: UploadKeyAt::PreActivation, environment: im::HashMap::new() }], + build_remotely: true, ..Default::default() }; @@ -271,4 +272,33 @@ mod tests { if logs.contains("The option `deployment._keys' is read-only, but it's set multiple times.") ); } + + #[tokio::test] + async fn test_force_always_local() { + let mut location: PathBuf = env::var("WIRE_TEST_DIR").unwrap().into(); + location.push("non_trivial_hive"); + let location = location!(location); + + let mut hive = Hive::new_from_path(&location, SubCommandModifiers::default()) + .await + .unwrap(); + + assert_matches!( + hive.force_always_local(vec!["non-existant".to_string()]), + Err(HiveLibError::HiveInitializationError( + HiveInitializationError::NodeDoesNotExist(node) + )) if node == "non-existant" + ); + + for node in hive.nodes.values() { + assert!(node.build_remotely); + } + + assert_matches!( + hive.force_always_local(vec!["node-a".to_string()]), + Ok(()) + ); + + assert!(!hive.nodes.get(&Name("node-a".into())).unwrap().build_remotely); + } } -- 2.51.2