From 4f1e41ebe3c1a034e24c5d633a13384ab379f40a Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 21 Jan 2024 13:08:34 -0500 Subject: [PATCH] test(update): demonstrate not able to `update --precise ` --- tests/testsuite/update.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index a36f187089f..fe2df05b955 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -1370,3 +1370,40 @@ fn update_precise_git_revisions() { assert!(p.read_lockfile().contains(&head_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() +}