#![allow(missing_docs)]
use worktree_io::repo_hooks_scaffold::SCAFFOLD;
use worktree_io::{config::Config, ttl::WorkspaceRegistry};
#[test]
fn test_worktree_toml_scaffold_content() {
insta::assert_snapshot!(SCAFFOLD);
}
#[test]
fn test_config_toml_default_content() {
insta::assert_snapshot!(Config::default().to_toml_with_comments());
}
#[test]
fn test_config_toml_all_fields() {
let mut c = Config::default();
c.editor.command = Some("code .".into());
c.open.editor = false;
c.hooks.pre_open = Some("cargo build".into());
c.hooks.post_open = Some("npm install".into());
c.set_value("workspace.ttl", "7days").unwrap();
c.set_value("workspace.auto_prune", "true").unwrap();
insta::assert_snapshot!(c.to_toml_with_comments());
}
#[test]
fn test_config_toml_path_suffix() {
let home = dirs::home_dir().expect("home dir must exist");
let path = Config::path().expect("Config::path() must succeed");
let suffix = path
.strip_prefix(&home)
.expect("config path must be under $HOME");
insta::assert_snapshot!(suffix.to_str().unwrap());
}
#[test]
fn test_workspaces_toml_path_suffix() {
let home = dirs::home_dir().expect("home dir must exist");
let path = WorkspaceRegistry::path().expect("WorkspaceRegistry::path() must succeed");
let suffix = path
.strip_prefix(&home)
.expect("registry path must be under $HOME");
insta::assert_snapshot!(suffix.to_str().unwrap());
}
#[test]
fn test_workspaces_toml_empty_content() {
let registry = WorkspaceRegistry::default();
let toml = toml::to_string(®istry).expect("serialization must succeed");
insta::assert_snapshot!(toml);
}