//! End-to-end test for `mcptest run --var KEY=VALUE`.
//!
//! Why a binary test? The unit tests in `cli.rs` already cover parser shape.
//! This one verifies that the resolver wiring runs end-to-end through the
//! shipped binary, so a regression in `crate::config::build_resolved` is
//! caught by `cargo test --workspace`.

use assert_cmd::Command;
use predicates::prelude::*;
use tempfile::tempdir;

fn mcptest() -> Command {
    Command::cargo_bin("mcptest").expect("binary builds")
}

#[test]
fn run_with_var_flag_succeeds_and_mentions_resolved_variable() {
    let dir = tempdir().unwrap();
    mcptest()
        .current_dir(dir.path())
        .args(["--verbose", "--var", "FOO=bar", "run"])
        .assert()
        .success()
        .stdout(predicate::str::contains("Resolved"))
        .stdout(predicate::str::contains("FOO"))
        .stdout(predicate::str::contains("CliFlag"))
        .stdout(predicate::str::contains("no config at"));
}

#[test]
fn run_without_verbose_does_not_print_resolved_summary() {
    let dir = tempdir().unwrap();
    mcptest()
        .current_dir(dir.path())
        .args(["--var", "FOO=bar", "run"])
        .assert()
        .success()
        .stdout(predicate::str::contains("Resolved").not())
        .stdout(predicate::str::contains("no config at"));
}
