use anyhow::Result;
use cueloop::contracts::{Task, TaskStatus};
use serde::Serialize;
use std::path::{Path, PathBuf};
use std::process::ExitStatus;
use tempfile::TempDir;
#[path = "../test_support.rs"]
mod test_support;
pub(super) fn setup_git_repo() -> Result<TempDir> {
let dir = test_support::temp_dir_outside_repo();
test_support::git_init(dir.path())?;
Ok(dir)
}
pub(super) fn setup_cueloop_repo() -> Result<TempDir> {
let dir = setup_git_repo()?;
test_support::seed_cueloop_dir(dir.path())?;
Ok(dir)
}
pub(super) fn trust_project_commands(dir: &Path) -> Result<()> {
test_support::trust_project_commands(dir)
}
pub(super) fn run_in_dir(dir: &Path, args: &[&str]) -> (ExitStatus, String, String) {
test_support::run_in_dir(dir, args)
}
pub(super) fn create_fake_runner(dir: &Path, runner: &str, script: &str) -> Result<PathBuf> {
test_support::create_fake_runner(dir, runner, script)
}
pub(super) fn configure_runner(
dir: &Path,
runner: &str,
model: &str,
runner_path: Option<&Path>,
) -> Result<()> {
test_support::configure_runner(dir, runner, model, runner_path)
}
pub(super) fn configure_ci_gate(
dir: &Path,
command: Option<&str>,
enabled: Option<bool>,
) -> Result<()> {
test_support::configure_ci_gate(dir, command, enabled)
}
pub(super) fn git_add_all_commit(dir: &Path, message: &str) -> Result<()> {
test_support::git_add_all_commit(dir, message)
}
pub(super) fn write_json_file<T: Serialize>(
dir: &Path,
name: &str,
document: &T,
) -> Result<PathBuf> {
let path = dir.join(name);
std::fs::write(&path, serde_json::to_string_pretty(document)?)?;
Ok(path)
}
pub(super) fn write_queue(dir: &Path, tasks: &[Task]) -> Result<()> {
test_support::write_queue(dir, tasks)
}
pub(super) fn write_done(dir: &Path, tasks: &[Task]) -> Result<()> {
test_support::write_done(dir, tasks)
}
pub(super) fn make_test_task(id: &str, title: &str, status: TaskStatus) -> Task {
test_support::make_test_task(id, title, status)
}