Files
imeai-aKode/akode-rs/worktree/tests/settings.rs
andrea.difonzo 7c1c6dfa8d Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
  nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 12:37:52 +01:00

77 lines
2.4 KiB
Rust

#![allow(clippy::expect_used)]
use akode_worktree::WorktreeSettings;
use pretty_assertions::assert_eq;
use serde_json::Value;
use serde_json::json;
use std::collections::HashMap;
fn desktop_config(entries: [(&str, Value); 3]) -> HashMap<String, Value> {
entries
.into_iter()
.map(|(key, value)| (key.to_owned(), value))
.collect()
}
#[test]
fn default_settings_match_desktop_worktree_defaults() {
let codex_home = tempfile::tempdir().expect("create Codex home");
let settings = WorktreeSettings::from_desktop_config(codex_home.path(), /*desktop*/ None)
.expect("load default worktree settings");
assert_eq!(
settings,
WorktreeSettings {
root: codex_home.path().join("worktrees"),
auto_cleanup_enabled: true,
keep_count: 15,
}
);
}
#[test]
fn desktop_settings_use_existing_root_and_retention_keys() {
let codex_home = tempfile::tempdir().expect("create Codex home");
let custom_root = codex_home.path().join("custom-managed-worktrees");
let desktop = desktop_config([
(
"git-worktree-root",
json!(custom_root.to_string_lossy().into_owned()),
),
("worktree-auto-cleanup-enabled", json!(false)),
("worktree-keep-count", json!(4)),
]);
let settings = WorktreeSettings::from_desktop_config(codex_home.path(), Some(&desktop))
.expect("load existing Desktop worktree settings");
assert_eq!(
settings,
WorktreeSettings {
root: custom_root,
auto_cleanup_enabled: false,
keep_count: 4,
}
);
}
#[test]
fn desktop_settings_reject_invalid_root_and_retention_values() {
let codex_home = tempfile::tempdir().expect("create Codex home");
let invalid_configs = [
HashMap::from([("git-worktree-root".to_owned(), json!("relative/worktrees"))]),
HashMap::from([("worktree-auto-cleanup-enabled".to_owned(), json!("yes"))]),
HashMap::from([("worktree-keep-count".to_owned(), json!(0))]),
HashMap::from([("worktree-keep-count".to_owned(), json!(-1))]),
HashMap::from([("worktree-keep-count".to_owned(), json!(1.5))]),
];
for desktop in invalid_configs {
assert!(
WorktreeSettings::from_desktop_config(codex_home.path(), Some(&desktop)).is_err(),
"invalid Desktop worktree settings were accepted: {desktop:?}",
);
}
}