Skip to content

Commit 4111e1a

Browse files
committed
Auto merge of #7741 - giraffate:add_test_for_cargo_pkgid, r=ehuss
Add test for `cargo pkgid` There was no test for `cargo pkgid` command.
2 parents feac578 + a28d9a1 commit 4111e1a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

tests/testsuite/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ mod package;
7272
mod patch;
7373
mod path;
7474
mod paths;
75+
mod pkgid;
7576
mod plugins;
7677
mod proc_macro;
7778
mod profile_config;

tests/testsuite/pkgid.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//! Tests for the `cargo pkgid` command.
2+
3+
use cargo_test_support::project;
4+
use cargo_test_support::registry::Package;
5+
6+
#[cargo_test]
7+
fn simple() {
8+
Package::new("bar", "0.1.0").publish();
9+
let p = project()
10+
.file(
11+
"Cargo.toml",
12+
r#"
13+
[package]
14+
name = "foo"
15+
version = "0.1.0"
16+
edition = "2018"
17+
18+
[dependencies]
19+
bar = "0.1.0"
20+
"#,
21+
)
22+
.file("src/main.rs", "fn main() {}")
23+
.build();
24+
25+
p.cargo("generate-lockfile").run();
26+
27+
p.cargo("pkgid foo")
28+
.with_stdout(format!("file://[..]{}#0.1.0", p.root().to_str().unwrap()))
29+
.run();
30+
31+
p.cargo("pkgid bar")
32+
.with_stdout("https://github.com/rust-lang/crates.io-index#bar:0.1.0")
33+
.run();
34+
}

0 commit comments

Comments
 (0)