test(lockfile): default lockfile version is still v3

It will become v4 when we changes the default.
This commit is contained in:
Weihang Lo 2024-09-24 17:32:29 -04:00
parent f30f909756
commit f3672cbf39
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7

View File

@ -1175,6 +1175,26 @@ fn v4_and_git_url_encoded_rev() {
#[cargo_test]
fn with_msrv() {
let cksum = Package::new("bar", "0.1.0").publish();
let v3_lockfile = format!(
r#"# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "bar"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "{cksum}"
[[package]]
name = "foo"
version = "0.0.1"
dependencies = [
"bar",
]
"#
);
let v2_lockfile = format!(
r#"# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
@ -1258,6 +1278,14 @@ dependencies = [
("1.53", Some(4), 4),
// v4 introduced
("1.78", None, 3),
// last version of v3 as the default
("1.82", None, 3),
// v4 is the default
("1.83", None, 3),
("1.83", Some(1), 1),
("1.83", Some(2), 2),
("1.83", Some(3), 3),
("1.83", Some(4), 4),
];
for (msrv, existing_lockfile, expected_version) in cases {
@ -1284,6 +1312,7 @@ dependencies = [
let existing_lockfile = match existing_lockfile {
1 => v1_lockfile.as_str().into(),
2 => v2_lockfile.as_str().into(),
3 => v3_lockfile.as_str().into(),
v => std::borrow::Cow::from(format!("version = {v}")),
};
p.change_file("Cargo.lock", &existing_lockfile);