use anyhow::{Context, Result};
use assert_cmd::Command;
use std::path::Path;
pub fn create_test_command() -> Result<Command> {
if cfg!(miri) {
return Err(anyhow::anyhow!("Skipping command tests under Miri"));
}
Command::cargo_bin("cargo-quickstart").context("Failed to find cargo-quickstart binary")
}
pub fn create_temp_project() -> Result<tempfile::TempDir> {
if cfg!(miri) {
return Err(anyhow::anyhow!("Skipping file system tests under Miri"));
}
tempfile::tempdir().context("Failed to create temporary directory")
}
pub fn assert_success_with_output(cmd: &mut Command, expected: &str) {
cmd.assert()
.success()
.stdout(predicates::str::contains(expected));
}
#[allow(dead_code)]
pub fn assert_failure_with_error(cmd: &mut Command, expected: &str) {
cmd.assert()
.failure()
.stderr(predicates::str::contains(expected));
}
#[allow(dead_code)]
pub fn assert_file_exists(dir: &Path, file: &str) {
assert!(dir.join(file).exists(), "Expected file {file} to exist");
}