use crate::{fs::TempRoot, prelude::{Ditto, DittoConfig, DittoConfigConnect, DittoError}};

pub fn setup_ditto() -> Result<(TempRoot, Ditto), DittoError> {
    let temp_root = TempRoot::new();
    let config = DittoConfig::new(
        crate::DatabaseId::generate().to_string(),
        DittoConfigConnect::SmallPeersOnly { private_key: None },
    )
    .with_persistence_directory(temp_root.root_path());
    let ditto = Ditto::open_sync(config)?;
    let _ = ditto.set_license_from_env("DITTO_LICENSE");
    Ok((temp_root, ditto))
}
