Files
fermata/tests/core_project.rs
T
Gabor KörberandClaude Opus 4.6 ac11512f62 ♻️ fermata: unify botignore.toml into .botsecrets [policy] sections
Delete botignore.toml as a config file entirely. Per-operation policy
rules (read/write/bash) now live in .botsecrets under [policy.read],
[policy.write], and [policy.bash]. This reduces fermata's config story
to two files: .botignore (gitignore syntax) and .botsecrets (TOML).

Changes:
- Add PolicyConfig, OpRules, BashRules to secrets/config.rs with
  layer merge support
- Rewrite policy.rs to load from SecretsConfig instead of BotignoreToml
- Remove toml_config.rs module entirely
- Remove botignore.toml from project root strong markers
- Update all tests to use .botsecrets [policy.*] sections
- Update error messages to reference .botsecrets

All 194 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-26 12:54:23 +02:00

98 lines
2.7 KiB
Rust

use dirigent_fermata::core::project::find_project_root;
use std::fs;
use tempfile::TempDir;
#[test]
fn finds_botsecrets_as_strong_marker() {
let tmp = TempDir::new().unwrap();
let root = tmp.path();
fs::create_dir_all(root.join("sub/deep")).unwrap();
fs::write(root.join(".botsecrets"), "").unwrap();
let target = root.join("sub/deep/file.rs");
fs::write(&target, "").unwrap();
let found = find_project_root(&target).unwrap();
assert_eq!(found, root);
}
#[test]
fn botignore_alone_does_not_stop_walk() {
let tmp = TempDir::new().unwrap();
let root = tmp.path();
fs::create_dir_all(root.join("a/b")).unwrap();
fs::create_dir_all(root.join(".git")).unwrap();
fs::write(root.join("a/.botignore"), "*.secret").unwrap();
let target = root.join("a/b/file.rs");
fs::write(&target, "").unwrap();
let found = find_project_root(&target).unwrap();
assert_eq!(found, root);
}
#[test]
fn botignore_used_as_fallback() {
let tmp = TempDir::new().unwrap();
let root = tmp.path();
fs::create_dir_all(root.join("sub")).unwrap();
fs::write(root.join(".botignore"), "*.secret").unwrap();
let target = root.join("sub/file.rs");
fs::write(&target, "").unwrap();
let found = find_project_root(&target).unwrap();
assert_eq!(found, root);
}
#[test]
fn strong_marker_preferred_over_botignore_fallback() {
let tmp = TempDir::new().unwrap();
let root = tmp.path();
fs::create_dir_all(root.join("a/b/c")).unwrap();
fs::create_dir_all(root.join(".git")).unwrap();
fs::write(root.join("a/b/.botignore"), "*.key").unwrap();
let target = root.join("a/b/c/file.rs");
fs::write(&target, "").unwrap();
let found = find_project_root(&target).unwrap();
assert_eq!(found, root);
}
#[test]
fn falls_back_to_git() {
let tmp = TempDir::new().unwrap();
let root = tmp.path();
fs::create_dir_all(root.join("sub")).unwrap();
fs::create_dir_all(root.join(".git")).unwrap();
let target = root.join("sub/file.rs");
fs::write(&target, "").unwrap();
let found = find_project_root(&target).unwrap();
assert_eq!(found, root);
}
#[test]
fn returns_none_when_no_marker() {
let tmp = TempDir::new().unwrap();
let target = tmp.path().join("file.rs");
std::fs::write(&target, "").unwrap();
assert!(find_project_root(&target).is_none());
}
#[test]
fn walks_up_from_file_path_not_cwd() {
let tmp = TempDir::new().unwrap();
let root = tmp.path();
fs::create_dir_all(root.join("a/b/c")).unwrap();
fs::write(root.join("a/.botsecrets"), "").unwrap();
let target = root.join("a/b/c/file.rs");
fs::write(&target, "").unwrap();
let found = find_project_root(&target).unwrap();
assert_eq!(found, root.join("a"));
}