crates/gunnar-ui-server/tests/default_build_links_no_shop.rs
//! **The AIRGAP default, held to the dependency graph** (owner rule 2026-10-25: the default
//! build makes zero outbound connections; every outbound surface is behind a default-off
//! feature). The shop relay, `monetize-site-buy` (the buyer's and the operator's doors, the
//! channel to the ONE monetize), is in this crate's normal tree ONLY under `metered`. The
//! default build does not contain it at all.
//!
//! Asked of cargo itself (`cargo tree`, offline, against this lock), because the claim is about
//! what cargo would compile, and only cargo can say that. `-e normal`: the testkit dev-edge is
//! the tests' own and is never linked into a binary.
use std::process::Command;
fn tree(features: &[&str]) -> 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", "gunnar-ui-server", "-e", "normal", "--prefix", "none"]);
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()
}
fn has_the_shop(tree: &str) -> bool {
tree.lines().any(|l| l.starts_with("monetize-site-buy "))
}
#[test]
fn the_default_build_does_not_contain_the_shop_relay() {
let default = tree(&[]);
assert!(default.lines().any(|l| l.starts_with("gunnar-ui-server ")), "the tree was read: {default}");
assert!(!has_the_shop(&default), "monetize-site-buy is in the DEFAULT build of gunnar-ui-server; the shop relay dials out and belongs behind `metered`");
}
#[test]
fn the_metered_build_does() {
assert!(has_the_shop(&tree(&["metered"])), "the metered build links the shop relay, or this test proves nothing");
}
#[test]
fn the_reader_sees_one_crate_by_its_own_line() {
assert!(has_the_shop("gunnar-ui-server v1.5.0\nmonetize-site-buy v0.1.3 (/src/monetize/crates/monetize-site-buy)\n"));
assert!(!has_the_shop("gunnar-ui-server v1.5.0\nmonetize-site-buy-extra v0.1.0\n"));
}