use crate::cleaner::ProjectDetector;
pub struct BazelDetector;
impl ProjectDetector for BazelDetector {
fn id(&self) -> &'static str {
"bazel"
}
fn display_name(&self) -> &'static str {
"Bazel"
}
fn detection_files(&self) -> &'static [&'static str] {
&["WORKSPACE", "WORKSPACE.bazel"]
}
fn artifact_dirs(&self) -> &'static [&'static str] {
&[] }
fn clean_command(&self) -> Option<&'static str> {
Some("bazel clean --expunge")
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::fs;
use tempfile::TempDir;
#[test]
fn test_bazel_detector_properties() {
let detector = BazelDetector;
assert_eq!(detector.id(), "bazel");
assert_eq!(detector.display_name(), "Bazel");
assert!(detector.artifact_dirs().is_empty());
assert_eq!(detector.clean_command(), Some("bazel clean --expunge"));
}
#[test]
fn test_bazel_detection_workspace() {
let tmp = TempDir::new().unwrap();
fs::write(tmp.path().join("WORKSPACE"), "").unwrap();
assert!(BazelDetector.detect(tmp.path()));
}
#[test]
fn test_bazel_detection_workspace_bazel() {
let tmp = TempDir::new().unwrap();
fs::write(tmp.path().join("WORKSPACE.bazel"), "").unwrap();
assert!(BazelDetector.detect(tmp.path()));
}
#[test]
fn test_bazel_no_detection() {
let tmp = TempDir::new().unwrap();
assert!(!BazelDetector.detect(tmp.path()));
}
}