Skip to content

Commit

Permalink
test: Add test about update --breaking on prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
linyihai committed Jul 15, 2024
1 parent 8b1d18a commit 0b801d1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cargo/util/toml_mut/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,10 @@ mod test {
assert_req_bump("1.1.1", "=1.0.0", "=1.1.1");
assert_req_bump("2.0.0", "=1.0.0", "=2.0.0");
}

#[test]
fn caret_prerelease() {
assert_req_bump("1.7.0", "2.0.0-beta.21", "1.7.0");
}
}
}
37 changes: 37 additions & 0 deletions tests/testsuite/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2616,3 +2616,40 @@ fn update_breaking_mixed_pinning_renaming() {
"#]],
);
}

#[cargo_test]
fn update_breaking_pre_release() {
Package::new("bar", "2.0.0-beta.21").publish();

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
edition = "2015"
authors = []
[dependencies]
bar = "2.0.0-beta.21"
"#,
)
.file("src/lib.rs", "")
.build();

p.cargo("generate-lockfile").run();

Package::new("bar", "1.7.0").publish();

p.cargo("update -Zunstable-options --breaking bar")
.masquerade_as_nightly_cargo(&["update-breaking"])
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[UPGRADING] bar ^2.0.0-beta.21 -> ^1.7.0
[LOCKING] 1 package to latest compatible version
[DOWNGRADING] bar v2.0.0-beta.21 -> v1.7.0
"#]])
.run();
}

0 comments on commit 0b801d1

Please sign in to comment.