fix: preserve authoritative settings through profile switches and refreshes

This commit is contained in:
objz committed 2026-10-01 23:23:26 +02:00
1 parent dc351df546
commit 00ba2faffe
23 files changed
+3768 -527

No files matched your search

+22
View File
@@ -3,6 +3,28 @@
use super::*;
#[test]
fn saving_settings_removes_deleted_environment_keys_and_keeps_retained_comments() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("config.toml");
std::fs::write(
&path,
"[defaults.environment]\nKEEP = 'old' # retained\nREMOVE = 'gone'\n[unknown]\nvalue = 1\n",
)
.unwrap();
let mut config = Config::default();
config
.defaults
.environment
.insert("KEEP".to_owned(), "new".to_owned());
write_config_document(&path, &config).unwrap();
let source = std::fs::read_to_string(&path).unwrap();
assert!(!source.contains("REMOVE"));
assert!(source.contains("# retained"));
assert!(source.contains("[unknown]"));
assert_eq!(load_config(&path).unwrap().defaults.environment.len(), 1);
}
#[test]
fn load_config_from_valid_toml() {
let tmp = tempfile::tempdir().unwrap();