use proptest::prelude::*;
use ricecoder_storage::PathResolver;
use std::path::PathBuf;
#[test]
fn prop_project_path_is_agent_directory() {
proptest!(|(_i in 0..100)| {
let project_path = PathResolver::resolve_project_path();
prop_assert_eq!(project_path, PathBuf::from(".agent"));
});
}
#[test]
fn test_project_path_consistency() {
let path1 = PathResolver::resolve_project_path();
let path2 = PathResolver::resolve_project_path();
let path3 = PathResolver::resolve_project_path();
assert_eq!(path1, path2);
assert_eq!(path2, path3);
assert_eq!(path1, PathBuf::from(".agent"));
}
#[test]
fn test_project_path_always_agent() {
let project_path = PathResolver::resolve_project_path();
assert_eq!(project_path.to_str().unwrap(), ".agent");
let components: Vec<_> = project_path.components().collect();
assert_eq!(components.len(), 1);
}
#[test]
fn test_project_path_can_join_subdirectories() {
let project_path = PathResolver::resolve_project_path();
let specs_path = project_path.join("specs");
assert_eq!(specs_path, PathBuf::from(".agent").join("specs"));
let steering_path = project_path.join("steering");
assert_eq!(steering_path, PathBuf::from(".agent").join("steering"));
let config_path = project_path.join("config");
assert_eq!(config_path, PathBuf::from(".agent").join("config"));
}
#[test]
fn prop_global_path_correctness() {
proptest!(|(_i in 0..100)| {
std::env::remove_var("RICECODER_HOME");
let global_path = PathResolver::resolve_global_path()
.expect("Should resolve global path");
let path_str = global_path.to_str().expect("Path should be valid UTF-8");
prop_assert!(
path_str.ends_with(".ricecoder") || path_str.ends_with(".ricecoder/"),
"Global path should end with .ricecoder, got: {}",
path_str
);
});
}
#[test]
fn test_global_path_ends_with_ricecoder() {
std::env::remove_var("RICECODER_HOME");
let global_path = PathResolver::resolve_global_path().expect("Should resolve global path");
let path_str = global_path.to_str().expect("Path should be valid UTF-8");
assert!(
path_str.ends_with(".ricecoder") || path_str.ends_with(".ricecoder/"),
"Global path should end with .ricecoder, got: {}",
path_str
);
}
#[test]
fn test_global_path_respects_ricecoder_home() {
let test_path = "/tmp/test-ricecoder";
std::env::set_var("RICECODER_HOME", test_path);
let global_path = PathResolver::resolve_global_path().expect("Should resolve global path");
assert_eq!(global_path, PathBuf::from(test_path));
std::env::remove_var("RICECODER_HOME");
}
#[test]
fn test_global_path_consistency() {
std::env::remove_var("RICECODER_HOME");
let path1 = PathResolver::resolve_global_path().expect("Should resolve global path");
let path2 = PathResolver::resolve_global_path().expect("Should resolve global path");
let path3 = PathResolver::resolve_global_path().expect("Should resolve global path");
assert_eq!(path1, path2);
assert_eq!(path2, path3);
}