test(generate-lockfile): verify --offline panics

This commit is contained in:
Weihang Lo 2024-03-26 16:52:24 -04:00
parent 5b2b1c036c
commit e186bf4e7a
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7

View File

@ -237,3 +237,41 @@ fn duplicate_entries_in_lockfile() {
)
.run();
}
#[cargo_test]
fn generate_lockfile_holds_lock_and_offline() {
Package::new("syn", "1.0.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
[dependencies]
syn = "1.0"
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("generate-lockfile")
.with_stderr(
"\
[UPDATING] `[..]` index
[LOCKING] 2 packages
",
)
.run();
p.cargo("generate-lockfile --offline")
.with_status(101)
.with_stderr_contains(
"\
[..]thread 'main' panicked[..]
[..]package cache lock is not currently held[..]
",
)
.run();
}