diff --git a/crates/xy/src/paths.rs b/crates/xy/src/paths.rs index fef2d81..b605af7 100644 --- a/crates/xy/src/paths.rs +++ b/crates/xy/src/paths.rs @@ -30,6 +30,7 @@ impl Paths { } pub fn ensure_dirs(&self) -> std::io::Result<()> { + std::fs::create_dir_all(&self.config_dir)?; std::fs::create_dir_all(&self.state_dir)?; std::fs::create_dir_all(&self.log_dir)?; Ok(()) @@ -45,4 +46,24 @@ mod tests { let p = Paths::resolve().unwrap(); assert!(p.pidfile.starts_with(&p.state_dir)); } + + #[test] + fn ensure_dirs_creates_all_paths() { + let tmp = tempfile::tempdir().unwrap(); + let root = tmp.path(); + + let paths = Paths { + config_dir: root.join("config/xy/servers"), + state_dir: root.join("state/xy"), + log_dir: root.join("state/xy/logs"), + socket: root.join("run/xy.sock"), + pidfile: root.join("state/xy/xy.pid"), + }; + + paths.ensure_dirs().unwrap(); + + assert!(paths.config_dir.is_dir()); + assert!(paths.state_dir.is_dir()); + assert!(paths.log_dir.is_dir()); + } }