crates/wg-appliance-core/tests/robot_is_opt_in.rs
//! **The podman robot is a test tool, so a runtime build does not carry it**
//! (A28 L14).
//!
//! [`wg_appliance_core::robot`] spawns `podman`/`docker` and drives a container
//! ceremony. It belongs to test harnesses only. It sits behind the `robot`
//! feature, which is not in `default`, so a consumer that links this crate for
//! its data plane never compiles it. Only tests and test callers turn it on.
const MANIFEST: &str = include_str!("../Cargo.toml");
/// The `[features]` lines of this crate's manifest, comments dropped.
fn feature_lines() -> Vec<String> {
let mut inside = false;
let mut lines = Vec::new();
for raw in MANIFEST.lines() {
let line = raw.split('#').next().unwrap_or("").trim();
if line.starts_with('[') {
inside = line == "[features]";
continue;
}
if inside && !line.is_empty() {
lines.push(line.to_string());
}
}
lines
}
#[test]
fn the_robot_has_its_own_feature_and_it_is_not_a_default() {
let lines = feature_lines();
assert!(
lines.iter().any(|l| l.starts_with("robot") && l.contains('=')),
"wg-appliance-core declares no `robot` feature: {lines:?}"
);
let default = lines.iter().find(|l| l.starts_with("default")).expect("a default feature list");
assert!(!default.contains("\"robot\""), "the podman robot is on by default: {default}");
}
/// With the feature on, the robot's API is reachable by name.
#[cfg(feature = "robot")]
#[test]
fn the_robot_feature_exposes_the_robot() {
let _engine: fn() -> Option<&'static str> = wg_appliance_core::robot::engine;
assert!(std::any::type_name::<wg_appliance_core::ContainerCeremony>().contains("robot::ContainerCeremony"));
}