//! End-to-end test for `--no-env-file` suppression.
//!
//! Verifies the operator-facing escape hatch: when a `.env` exists in the
//! working directory but `--no-env-file` is passed, doctor reports that
//! auto-discovery is disabled and does not load the file.

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

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

#[test]
fn no_env_file_skips_auto_discovery_in_doctor() {
    let dir = tempdir().unwrap();
    std::fs::write(dir.path().join(".env"), "FOO_FROM_DOTENV=present\n").unwrap();

    mcptest()
        .current_dir(dir.path())
        .args(["--no-env-file", "doctor"])
        .assert()
        .success()
        .stdout(predicate::str::contains("disabled"))
        .stdout(predicate::str::contains("FOO_FROM_DOTENV").not());
}
