Skip to content

Commit

Permalink
Auto merge of #7741 - giraffate:add_test_for_cargo_pkgid, r=ehuss
Browse files Browse the repository at this point in the history
Add test for `cargo pkgid`

There was no test for `cargo pkgid` command.
  • Loading branch information
bors committed Dec 29, 2019
2 parents feac578 + a28d9a1 commit 4111e1a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/testsuite/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ mod package;
mod patch;
mod path;
mod paths;
mod pkgid;
mod plugins;
mod proc_macro;
mod profile_config;
Expand Down
34 changes: 34 additions & 0 deletions tests/testsuite/pkgid.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 4111e1a

Please sign in to comment.