From a28d9a1e2af548a6f4bb0cc022936711b2cb107d Mon Sep 17 00:00:00 2001 From: Takayuki Nakata Date: Tue, 24 Dec 2019 17:52:57 +0900 Subject: [PATCH] Add test for `cargo pkgid` --- tests/testsuite/main.rs | 1 + tests/testsuite/pkgid.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/testsuite/pkgid.rs diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index c96bf906820..9c1c1913e36 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -72,6 +72,7 @@ mod package; mod patch; mod path; mod paths; +mod pkgid; mod plugins; mod proc_macro; mod profile_config; diff --git a/tests/testsuite/pkgid.rs b/tests/testsuite/pkgid.rs new file mode 100644 index 00000000000..00ffbb56c1a --- /dev/null +++ b/tests/testsuite/pkgid.rs @@ -0,0 +1,34 @@ +//! Tests for the `cargo pkgid` command. + +use cargo_test_support::project; +use cargo_test_support::registry::Package; + +#[cargo_test] +fn simple() { + Package::new("bar", "0.1.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2018" + + [dependencies] + bar = "0.1.0" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("generate-lockfile").run(); + + p.cargo("pkgid foo") + .with_stdout(format!("file://[..]{}#0.1.0", p.root().to_str().unwrap())) + .run(); + + p.cargo("pkgid bar") + .with_stdout("https://github.com/rust-lang/crates.io-index#bar:0.1.0") + .run(); +}