Skip to content

Commit e186bf4

Browse files
committed
test(generate-lockfile): verify --offline panics
1 parent 5b2b1c0 commit e186bf4

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/testsuite/generate_lockfile.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,41 @@ fn duplicate_entries_in_lockfile() {
237237
)
238238
.run();
239239
}
240+
241+
#[cargo_test]
242+
fn generate_lockfile_holds_lock_and_offline() {
243+
Package::new("syn", "1.0.0").publish();
244+
245+
let p = project()
246+
.file(
247+
"Cargo.toml",
248+
r#"
249+
[package]
250+
name = "foo"
251+
252+
[dependencies]
253+
syn = "1.0"
254+
"#,
255+
)
256+
.file("src/lib.rs", "")
257+
.build();
258+
259+
p.cargo("generate-lockfile")
260+
.with_stderr(
261+
"\
262+
[UPDATING] `[..]` index
263+
[LOCKING] 2 packages
264+
",
265+
)
266+
.run();
267+
268+
p.cargo("generate-lockfile --offline")
269+
.with_status(101)
270+
.with_stderr_contains(
271+
"\
272+
[..]thread 'main' panicked[..]
273+
[..]package cache lock is not currently held[..]
274+
",
275+
)
276+
.run();
277+
}

0 commit comments

Comments
 (0)