Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/holger

xtask/tests/the_airgap_build_mails_nothing.rs

//! ★ **The default build is the airgap install** (owner 2026-10-25): it links no mail sender
//! at all, and the metered build links the ONE shared sender (monetize `monetize-mail`, with
//! its `egress` feature for a box behind its front) and no SMTP client of Holger's own.
//! Asserted both ways, so a tree that resolved to nothing cannot pass the absence half.

use std::process::Command;

fn tree(extra: &[&str]) -> String {
    let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
        .parent()
        .expect("the workspace root")
        .to_path_buf();
    let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into());
    let mut args = vec![
        "tree",
        "-p",
        "holger",
        "-e",
        "normal,build",
        "--prefix",
        "none",
        "--format",
        "{p} {f}",
    ];
    args.extend_from_slice(extra);
    let out = Command::new(&cargo)
        .current_dir(&root)
        .args(&args)
        .output()
        .expect("cargo tree runs");
    assert!(
        out.status.success(),
        "cargo {}: {}",
        args.join(" "),
        String::from_utf8_lossy(&out.stderr)
    );
    String::from_utf8_lossy(&out.stdout).into_owned()
}

fn has(tree: &str, name: &str) -> bool {
    tree.lines().any(|l| l.starts_with(&format!("{name} v")))
}

#[test]
fn the_default_build_links_no_mail_sender_and_the_metered_one_the_shared_one() {
    let default = tree(&[]);
    assert!(
        has(&default, "holger"),
        "the default tree is the server's:\n{default}"
    );
    for sender in ["monetize-mail", "lettre"] {
        assert!(
            !has(&default, sender),
            "the default (airgap) build links {sender}:\n{default}"
        );
    }
    let metered = tree(&["--features", "metered"]);
    assert!(
        has(&metered, "monetize-mail"),
        "the metered build mails through monetize-mail:\n{metered}"
    );
    assert!(
        metered
            .lines()
            .any(|l| l.starts_with("monetize-mail v") && l.contains("egress")),
        "monetize-mail with its `egress` feature (a box behind its front):\n{metered}"
    );
}