#![allow(dead_code)]
use gixor::{Error, Gixor, GixorFactory, Result};
use std::path::PathBuf;
use std::sync::OnceLock;
fn manifest_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
}
pub fn integration_dir() -> PathBuf {
manifest_dir().join("integration")
}
pub fn config_path() -> PathBuf {
let path = manifest_dir().join("testdata").join("config.json");
assert!(
path.exists(),
"{}: the test configuration is missing",
path.display()
);
path
}
pub fn setup() -> Result<Gixor> {
let dir = integration_dir();
let _ = std::fs::create_dir_all(&dir);
let config = dir.join("config.json");
let gixor = match GixorFactory::load(&config) {
Ok(gixor) => gixor,
Err(_) => GixorFactory::new_at(&config),
};
static PREPARED: OnceLock<Result<()>> = OnceLock::new();
match PREPARED.get_or_init(|| gixor.prepare(false)) {
Ok(_) => Ok(gixor),
Err(e) => Err(Error::Fatal(format!("failed to prepare the repositories: {e}"))),
}
}