test(update): demonstrate not able to update --precise <yanked>

This commit is contained in:
Weihang Lo 2024-01-21 13:08:34 -05:00
parent 515f6e3f9d
commit 4f1e41ebe3
No known key found for this signature in database
GPG key ID: D7DBF189825E82E7

View file

@ -1370,3 +1370,40 @@ fn update_precise_git_revisions() {
assert!(p.read_lockfile().contains(&head_id)); assert!(p.read_lockfile().contains(&head_id));
assert!(!p.read_lockfile().contains(&tag_commit_id)); assert!(!p.read_lockfile().contains(&tag_commit_id));
} }
#[cargo_test]
fn precise_yanked() {
Package::new("bar", "0.1.0").publish();
Package::new("bar", "0.1.1").yanked(true).publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
[dependencies]
bar = "0.1"
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("generate-lockfile").run();
// Use non-yanked version.
let lockfile = p.read_lockfile();
assert!(lockfile.contains("\nname = \"bar\"\nversion = \"0.1.0\""));
p.cargo("update --precise 0.1.1 bar")
.with_status(101)
.with_stderr(
"\
[UPDATING] `dummy-registry` index
[ERROR] no matching package named `bar` found
location searched: registry `crates-io`
required by package `foo v0.0.0 ([CWD])`
",
)
.run()
}