#[path = "boundary.rs"]
mod boundary;
#[path = "cloud.rs"]
mod cloud;
pub mod loader;
pub mod parser;
pub mod path_resolver;
pub mod truncation;
pub mod types;
pub mod unified;
pub mod validation;
pub use cloud::{
CloudConfig, CloudStateConfig, GitAuthMethod, GitAuthStateMethod, GitRemoteConfig,
GitRemoteStateConfig,
};
pub use types::{Config, ReviewDepth, Verbosity};
pub use unified::{
unified_config_path, CcsAliasConfig, CcsConfig, ConfigInitResult as UnifiedConfigInitResult,
UnifiedConfig,
};
pub use path_resolver::{ConfigEnvironment, MemoryConfigEnvironment, RealConfigEnvironment};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_verbosity_from_u8() {
assert_eq!(Verbosity::from(0), Verbosity::Quiet);
assert_eq!(Verbosity::from(1), Verbosity::Normal);
assert_eq!(Verbosity::from(2), Verbosity::Verbose);
assert_eq!(Verbosity::from(3), Verbosity::Full);
assert_eq!(Verbosity::from(4), Verbosity::Debug);
assert_eq!(Verbosity::from(100), Verbosity::Debug);
}
#[test]
fn test_truncate_limits() {
assert_eq!(Verbosity::Quiet.truncate_limit("text"), 80);
assert_eq!(Verbosity::Quiet.truncate_limit("tool_input"), 40);
assert_eq!(Verbosity::Normal.truncate_limit("text"), 1000);
assert_eq!(Verbosity::Normal.truncate_limit("tool_input"), 300);
assert_eq!(Verbosity::Normal.truncate_limit("tool_result"), 500);
assert_eq!(Verbosity::Verbose.truncate_limit("text"), 2000);
assert_eq!(Verbosity::Verbose.truncate_limit("tool_input"), 300);
assert_eq!(Verbosity::Verbose.truncate_limit("tool_result"), 500);
assert_eq!(Verbosity::Full.truncate_limit("text"), 999_999);
assert_eq!(Verbosity::Debug.truncate_limit("text"), 999_999);
}
#[test]
fn test_verbosity_helpers() {
assert!(!Verbosity::Quiet.is_debug());
assert!(!Verbosity::Normal.is_debug());
assert!(!Verbosity::Verbose.is_debug());
assert!(!Verbosity::Full.is_debug());
assert!(Verbosity::Debug.is_debug());
assert!(!Verbosity::Quiet.is_verbose());
assert!(!Verbosity::Normal.is_verbose());
assert!(Verbosity::Verbose.is_verbose());
assert!(Verbosity::Full.is_verbose());
assert!(Verbosity::Debug.is_verbose());
assert!(!Verbosity::Quiet.show_tool_input());
assert!(Verbosity::Normal.show_tool_input());
assert!(Verbosity::Verbose.show_tool_input());
assert!(Verbosity::Full.show_tool_input());
assert!(Verbosity::Debug.show_tool_input());
}
#[test]
fn test_review_depth_from_str() {
assert_eq!(
ReviewDepth::from_str("standard"),
Some(ReviewDepth::Standard)
);
assert_eq!(
ReviewDepth::from_str("default"),
Some(ReviewDepth::Standard)
);
assert_eq!(ReviewDepth::from_str("normal"), Some(ReviewDepth::Standard));
assert_eq!(
ReviewDepth::from_str("comprehensive"),
Some(ReviewDepth::Comprehensive)
);
assert_eq!(
ReviewDepth::from_str("thorough"),
Some(ReviewDepth::Comprehensive)
);
assert_eq!(
ReviewDepth::from_str("full"),
Some(ReviewDepth::Comprehensive)
);
assert_eq!(
ReviewDepth::from_str("security"),
Some(ReviewDepth::Security)
);
assert_eq!(ReviewDepth::from_str("secure"), Some(ReviewDepth::Security));
assert_eq!(
ReviewDepth::from_str("security-focused"),
Some(ReviewDepth::Security)
);
assert_eq!(
ReviewDepth::from_str("incremental"),
Some(ReviewDepth::Incremental)
);
assert_eq!(
ReviewDepth::from_str("diff"),
Some(ReviewDepth::Incremental)
);
assert_eq!(
ReviewDepth::from_str("changed"),
Some(ReviewDepth::Incremental)
);
assert_eq!(
ReviewDepth::from_str("SECURITY"),
Some(ReviewDepth::Security)
);
assert_eq!(
ReviewDepth::from_str("Comprehensive"),
Some(ReviewDepth::Comprehensive)
);
assert_eq!(ReviewDepth::from_str("invalid"), None);
assert_eq!(ReviewDepth::from_str(""), None);
}
#[test]
fn test_review_depth_default() {
assert_eq!(ReviewDepth::default(), ReviewDepth::Standard);
}
#[test]
fn test_review_depth_description() {
assert!(ReviewDepth::Standard.description().contains("Balanced"));
assert!(ReviewDepth::Comprehensive
.description()
.contains("In-depth"));
assert!(ReviewDepth::Security.description().contains("OWASP"));
assert!(ReviewDepth::Incremental.description().contains("git diff"));
}
}