use crate::config::guard::{ProtectedFile, deny_if_would_break, parses};
use std::path::Path;
#[test]
fn valid_config_parses() {
assert!(parses(ProtectedFile::Config, "[agent]\n").is_ok());
assert!(parses(ProtectedFile::Config, "").is_ok());
}
#[test]
fn broken_toml_is_rejected_for_config() {
assert!(parses(ProtectedFile::Config, "allowed = [\n").is_err());
assert!(parses(ProtectedFile::Config, "key =\n").is_err());
}
#[test]
fn valid_keys_parse() {
assert!(parses(ProtectedFile::Keys, "[providers]\n").is_ok());
assert!(parses(ProtectedFile::Keys, "").is_ok());
}
#[test]
fn broken_toml_is_rejected_for_keys() {
assert!(parses(ProtectedFile::Keys, "[providers\n").is_err());
assert!(parses(ProtectedFile::Keys, "token = \"unterminated\n").is_err());
}
#[test]
fn non_protected_path_is_never_denied() {
let some_project = Path::new("/tmp/some-project/config.toml");
assert!(deny_if_would_break(some_project, "totally [ broken").is_ok());
}