use std::path::PathBuf;
use std::process::Command;
use tempfile::TempDir;
pub struct TestHelper {
_temp_dir: TempDir, pub repo_path: PathBuf,
}
impl TestHelper {
pub fn new() -> anyhow::Result<Self> {
let temp_dir = TempDir::new()?;
let repo_path = temp_dir.path().to_path_buf();
Command::new("git")
.args(["init"])
.current_dir(&repo_path)
.output()?;
Ok(Self {
_temp_dir: temp_dir,
repo_path,
})
}
pub fn run_gwtr(&self, args: &[&str]) -> std::process::Output {
Command::new(env!("CARGO_BIN_EXE_gwtr"))
.args(args)
.current_dir(&self.repo_path)
.output()
.expect("Failed to execute gwtr")
}
}