holger-estate-front/tests/public_site_off_by_default.rs
//! **The front's default build is the AIRGAP install** (TASKS-12 S-6, the
//! owner's SLIM and AIRGAP rules, 2026-10-25): holger-ui's `holger-public-site`
//! (robots.txt, the sitemap, llms.txt and the front page's head tags; it holds
//! no HTTP client) is in this front's tree only under its `public-site`
//! feature, never in the default or the metered build. Asked of cargo itself.
use std::process::Command;
fn tree(features: &[&str], no_default: bool) -> String {
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_owned());
let manifest = concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml");
let mut cmd = Command::new(cargo);
cmd.args([
"tree",
"--offline",
"--locked",
"--manifest-path",
manifest,
"-p",
"holger-estate-front",
"-e",
"normal",
"--prefix",
"none",
]);
if no_default {
cmd.arg("--no-default-features");
}
if !features.is_empty() {
cmd.args(["--features", &features.join(",")]);
}
let out = cmd.output().expect("cargo tree runs");
assert!(
out.status.success(),
"cargo tree failed: {}",
String::from_utf8_lossy(&out.stderr)
);
String::from_utf8_lossy(&out.stdout).into_owned()
}
#[test]
fn the_default_front_does_not_contain_the_public_site() {
let t = tree(&[], false);
assert!(
t.contains("holger-ui-server"),
"the default front carries the console: {t}"
);
assert!(
!t.contains("holger-public-site"),
"the default front links the public site:\n{t}"
);
}
#[test]
fn the_metered_front_does_not_contain_it_either() {
assert!(!tree(&["console", "metered"], true).contains("holger-public-site"));
}
#[test]
fn the_public_site_front_does() {
assert!(tree(&["console", "metered", "public-site"], true).contains("holger-public-site"));
}
#[test]
fn the_feature_is_off_by_default() {
let m = std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml")).unwrap();
assert!(
m.lines()
.any(|l| l.trim() == r#"public-site = ["console", "holger-ui-server?/public-site"]"#),
"no public-site feature"
);
let default = m
.lines()
.find(|l| l.starts_with("default = "))
.expect("a default line");
assert!(!default.contains("public-site"), "{default}");
}