-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |