use std::fs;

use tempfile::TempDir;

#[tokio::test]
async fn errors_without_config_or_project() {
    let tmp = TempDir::new().unwrap();
    let args = donion::Cli {
        dir: tmp.path().to_path_buf(),
        command: None,
    };
    let result = donion::run(args).await;
    assert!(result.is_err());
}

#[tokio::test]
async fn errors_with_invalid_config() {
    let tmp = TempDir::new().unwrap();
    fs::write(tmp.path().join("donion.toml"), "invalid toml [[[").unwrap();

    let args = donion::Cli {
        dir: tmp.path().to_path_buf(),
        command: None,
    };
    let result = donion::run(args).await;
    assert!(result.is_err());
}
