use crate::config::Config;
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct ScanContext {
pub paths: Vec<PathBuf>,
pub config: Config,
pub verbose: bool,
pub strict: bool,
}
impl ScanContext {
pub fn new(paths: Vec<PathBuf>, config: Config) -> Self {
Self {
paths,
config,
verbose: false,
strict: false,
}
}
pub fn with_verbose(mut self, verbose: bool) -> Self {
self.verbose = verbose;
self
}
pub fn with_strict(mut self, strict: bool) -> Self {
self.strict = strict;
self
}
}
impl Default for ScanContext {
fn default() -> Self {
Self::new(Vec::new(), Config::default())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_scan_context_builder() {
let ctx = ScanContext::new(vec![PathBuf::from(".")], Config::default())
.with_verbose(true)
.with_strict(true);
assert!(ctx.verbose);
assert!(ctx.strict);
}
#[test]
fn test_scan_context_default() {
let ctx = ScanContext::default();
assert!(ctx.paths.is_empty());
assert!(!ctx.verbose);
assert!(!ctx.strict);
}
#[test]
fn test_scan_context_new() {
let paths = vec![PathBuf::from("/test/path")];
let ctx = ScanContext::new(paths.clone(), Config::default());
assert_eq!(ctx.paths, paths);
assert!(!ctx.verbose);
assert!(!ctx.strict);
}
#[test]
fn test_scan_context_debug() {
let ctx = ScanContext::default();
let debug_str = format!("{:?}", ctx);
assert!(debug_str.contains("ScanContext"));
}
#[test]
fn test_scan_context_clone() {
let ctx = ScanContext::new(vec![PathBuf::from(".")], Config::default()).with_verbose(true);
let cloned = ctx.clone();
assert_eq!(ctx.paths, cloned.paths);
assert_eq!(ctx.verbose, cloned.verbose);
}
}