Step 11: Add Tests
Create comprehensive tests co-located with each module:
#![allow(unused)]
fn main() {
#[cfg(test)]
mod tests {
use super::*;
fn test_uri() -> url::Url {
// `deps_core::test_util::test_uri("/test/{manifest_file}")` builds the same thing
// (and handles the Windows `C:` prefix) — prefer it over hand-rolling this helper.
url::Url::parse("file:///test/{manifest_file}").unwrap()
}
#[test]
fn test_parse_simple_dependencies() {
let content = r#"..."#;
let result = parse_{manifest}(content, &test_uri()).unwrap();
assert!(!result.dependencies.is_empty());
}
#[test]
fn test_position_tracking() {
let content = r#"..."#;
let result = parse_{manifest}(content, &test_uri()).unwrap();
let dep = &result.dependencies[0];
// Verify positions are correct
assert!(dep.name_range.start.line > 0);
assert!(dep.version_range.is_some());
}
#[tokio::test]
async fn test_ecosystem_trait() {
let cache = Arc::new(HttpCache::new());
let ecosystem = {Ecosystem}Ecosystem::new(cache);
assert_eq!(ecosystem.id(), "{ecosystem_id}");
assert!(ecosystem.manifest_filenames().contains(&"{manifest_file}"));
}
}
}