caretta-sync-core 0.0.2

A local-first application framework for lazy person
Documentation
use std::{path::PathBuf, sync::LazyLock};

use crate::config::{
    Config, PartialConfig, PartialIrohConfig, PartialRpcConfig, RpcConfig, StorageConfig,
};
use tempfile::TempDir;
use url::Url;

use serde::{Deserialize, Serialize, de::DeserializeOwned};

pub static TEST_CONFIG: LazyLock<Config> = LazyLock::new(|| {
    let test_dir = tempfile::Builder::new()
        .prefix("caretta-sync")
        .tempdir()
        .unwrap()
        .keep();
    let data_dir = test_dir.join("data");
    let cache_dir = test_dir.join("cache");

    Config {
        iroh: PartialIrohConfig::default()
            .with_new_secret_key()
            .try_into()
            .unwrap(),
        storage: StorageConfig {
            data_directory: data_dir,
            cache_directory: cache_dir,
        },
        rpc: RpcConfig {
            endpoint_url: Url::parse(
                &(String::from("unix://") + test_dir.join("socket.sock").to_str().unwrap()),
            )
            .unwrap(),
        },
    }
});