Introduce origin config

main
Brian Picciano 12 months ago
parent 254d9c63d0
commit 9c1bdc1e8a
  1. 6
      src/main.rs
  2. 12
      src/origin.rs
  3. 7
      src/origin/config.rs
  4. 10
      src/origin/git.rs

@ -73,7 +73,11 @@ async fn main() {
)
.init();
let origin_store = domani::origin::git::FSStore::new(config.origin_store_git_dir_path)
let origin_config = domani::origin::Config {
store_dir_path: config.origin_store_git_dir_path,
};
let origin_store = domani::origin::git::FSStore::new(&origin_config)
.expect("git origin store initialization failed");
let domain_checker = domani::domain::checker::DNSChecker::new(

@ -1,13 +1,15 @@
use crate::error::unexpected;
use crate::util;
use std::sync;
mod config;
mod descr;
pub mod git;
pub mod mux;
mod descr;
pub use config::*;
pub use descr::Descr;
use crate::error::unexpected;
use crate::util;
use std::sync;
#[derive(thiserror::Error, Clone, Debug, PartialEq)]
pub enum SyncError {
#[error("invalid url")]

@ -0,0 +1,7 @@
use serde::Deserialize;
use std::path;
#[derive(Deserialize)]
pub struct Config {
pub store_dir_path: path::PathBuf,
}

@ -34,7 +34,8 @@ pub struct FSStore {
}
impl FSStore {
pub fn new(dir_path: PathBuf) -> io::Result<Self> {
pub fn new(config: &origin::Config) -> io::Result<Self> {
let dir_path = config.store_dir_path.clone();
fs::create_dir_all(&dir_path)?;
Ok(Self {
dir_path,
@ -336,13 +337,16 @@ impl super::Store for FSStore {
#[cfg(test)]
mod tests {
use crate::origin::{self, Store};
use crate::origin::{self, Config, Store};
use futures::StreamExt;
use tempdir::TempDir;
#[tokio::test]
async fn basic() {
let tmp_dir = TempDir::new("origin_store_git").unwrap();
let config = Config {
store_dir_path: tmp_dir.path().to_path_buf(),
};
let curr_dir = format!("file://{}", std::env::current_dir().unwrap().display());
@ -356,7 +360,7 @@ mod tests {
branch_name: String::from("some_other_branch"),
};
let store = super::FSStore::new(tmp_dir.path().to_path_buf()).expect("store created");
let store = super::FSStore::new(&config).expect("store created");
store.sync(&descr).expect("sync should succeed");
store.sync(&descr).expect("second sync should succeed");

Loading…
Cancel
Save