Skip to content

Commit

Permalink
test(spec): Cover meta/pre cases for partial versions
Browse files Browse the repository at this point in the history
We already tested with missing minor/patch
  • Loading branch information
epage committed Oct 18, 2023
1 parent 5f856f7 commit ca6a57f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/cargo/core/package_id_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,5 +453,41 @@ mod tests {
assert!(PackageIdSpec::parse("[email protected]").unwrap().matches(foo));
assert!(!PackageIdSpec::parse("[email protected]").unwrap().matches(foo));
assert!(PackageIdSpec::parse("[email protected]").unwrap().matches(foo));

let meta = PackageId::new("meta", "1.2.3+hello", sid).unwrap();
assert!(PackageIdSpec::parse("meta").unwrap().matches(meta));
assert!(PackageIdSpec::parse("meta@1").unwrap().matches(meta));
assert!(PackageIdSpec::parse("[email protected]").unwrap().matches(meta));
assert!(PackageIdSpec::parse("[email protected]").unwrap().matches(meta));
assert!(!PackageIdSpec::parse("[email protected]")
.unwrap()
.matches(meta));
assert!(PackageIdSpec::parse("[email protected]+hello")
.unwrap()
.matches(meta));
assert!(PackageIdSpec::parse("[email protected]+bye")
.unwrap()
.matches(meta));

let pre = PackageId::new("pre", "1.2.3-alpha.0", sid).unwrap();
assert!(PackageIdSpec::parse("pre").unwrap().matches(pre));
assert!(!PackageIdSpec::parse("pre@1").unwrap().matches(pre));
assert!(!PackageIdSpec::parse("[email protected]").unwrap().matches(pre));
assert!(!PackageIdSpec::parse("[email protected]").unwrap().matches(pre));
assert!(PackageIdSpec::parse("[email protected]")
.unwrap()
.matches(pre));
assert!(!PackageIdSpec::parse("[email protected]")
.unwrap()
.matches(pre));
assert!(!PackageIdSpec::parse("[email protected]")
.unwrap()
.matches(pre));
assert!(!PackageIdSpec::parse("[email protected]+hello")
.unwrap()
.matches(pre));
assert!(PackageIdSpec::parse("[email protected]+hello")
.unwrap()
.matches(pre));
}
}

0 comments on commit ca6a57f

Please sign in to comment.