crates/gunnar-front/tests/mcp_off_by_default.rs
//! **The front's default build has no MCP connector** (TASKS-13, the SLIM
//! RULE): `gunnar-mcp` is in gunnar-front's tree only under its `mcp`
//! feature, and neither the default nor the metered build turns it on.
//! Asked of cargo itself (`cargo tree`, offline, against this lock).
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",
"gunnar-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_mcp_connector() {
let t = tree(&[], false);
assert!(
t.contains("gunnar-ui-server"),
"the default front carries the console: {t}"
);
assert!(
!t.contains("gunnar-mcp"),
"the default front links the MCP connector:\n{t}"
);
}
#[test]
fn the_metered_front_does_not_contain_it_either() {
assert!(!tree(&["metered"], false).contains("gunnar-mcp"));
}
#[test]
fn the_mcp_front_does() {
assert!(tree(&["mcp"], false).contains("gunnar-mcp"));
}
#[test]
fn the_feature_is_off_by_default_and_in_no_release_row() {
let manifest =
std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml")).unwrap();
let default = manifest
.lines()
.find(|l| l.starts_with("default = "))
.expect("a default line");
assert!(!default.contains("mcp"), "{default}");
let metered = manifest
.lines()
.find(|l| l.starts_with("metered = "))
.expect("a metered line");
assert!(!metered.contains("mcp"), "{metered}");
let variants = std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../.nornir/build-variants.toml"
))
.unwrap();
assert!(
!variants.contains("\"mcp\""),
"a release row turns the MCP connector on; that is the owner's call"
);
}