Skip to content

Commit f07d4e6

Browse files
committed
Add testcase
1 parent fd32b5b commit f07d4e6

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

crates/node/src/registry.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,28 @@ mod tests {
930930
assert_eq!(result, Some("2.0.0".to_owned()));
931931
}
932932

933+
#[test]
934+
fn test_select_version_minor_skips_prerelease_when_current_stable() {
935+
// Exercises accept_pre_aware: stable current + prerelease candidate in same
936+
// major → prerelease must be rejected (covers the `!current_is_prerelease`
937+
// early-return branch inside accept_pre_aware).
938+
let latest = "18.2.0".to_owned();
939+
let versions = make_versions(&["18.0.0", "18.1.0", "18.2.0", "18.3.0-beta.1"]);
940+
let result = select_version("^18.0.0", Some(&latest), &versions, TargetLevel::Minor);
941+
// Stable 18.2.0 wins over 18.3.0-beta.1 because current is stable.
942+
assert_eq!(result, Some("18.2.0".to_owned()));
943+
}
944+
945+
#[test]
946+
fn test_select_version_patch_skips_prerelease_when_current_stable() {
947+
// Same as above, but on the Patch branch, so the iterator walks a
948+
// prerelease candidate on the same major.minor and must reject it.
949+
let latest = "18.0.5".to_owned();
950+
let versions = make_versions(&["18.0.0", "18.0.1", "18.0.5", "18.0.6-rc.1"]);
951+
let result = select_version("=18.0.0", Some(&latest), &versions, TargetLevel::Patch);
952+
assert_eq!(result, Some("18.0.5".to_owned()));
953+
}
954+
933955
#[tokio::test]
934956
async fn test_resolve_version_non_latest_with_tracing() {
935957
use wiremock::matchers::{method, path};

crates/python/src/parser.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,21 @@ dependencies = [
587587
assert!(dep.is_none());
588588
}
589589

590+
#[test]
591+
fn test_parse_pep508_wildcard_version_rejected() {
592+
// A PEP 508 spec that carries a wildcard version like `pkg==*` must be
593+
// filtered out at parse time — there's nothing meaningful to update.
594+
let dep = parse_pep508_spec("requests==*", DependencySection::ProjectDependencies);
595+
assert!(dep.is_none());
596+
}
597+
598+
#[test]
599+
fn test_parse_pep508_bare_star_rejected() {
600+
// `pkg *` should also be rejected via is_wildcard_req.
601+
let dep = parse_pep508_spec("requests *", DependencySection::ProjectDependencies);
602+
assert!(dep.is_none());
603+
}
604+
590605
#[test]
591606
fn test_invalid_toml_returns_error() {
592607
let result = PyProjectManifest::parse("not valid [[[toml");

0 commit comments

Comments
 (0)