Skip to content

Commit

Permalink
Migrate from tests fom assert_that/execs to .run()
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Aug 28, 2018
1 parent b5ee363 commit 85984a8
Show file tree
Hide file tree
Showing 83 changed files with 8,461 additions and 12,730 deletions.
243 changes: 97 additions & 146 deletions tests/testsuite/alt_registry.rs

Large diffs are not rendered by default.

483 changes: 194 additions & 289 deletions tests/testsuite/bad_config.rs

Large diffs are not rendered by default.

77 changes: 35 additions & 42 deletions tests/testsuite/bad_manifest_path.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
use support::{basic_bin_manifest, execs, main_file, project};
use support::hamcrest::assert_that;
use support::{basic_bin_manifest, main_file, project};

fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.build();

assert_that(
p.cargo(command)
.arg("--manifest-path")
.arg(manifest_path_argument)
.cwd(p.root().parent().unwrap()),
execs().with_status(101).with_stderr(
p.cargo(command)
.arg("--manifest-path")
.arg(manifest_path_argument)
.cwd(p.root().parent().unwrap())
.with_status(101)
.with_stderr(
"[ERROR] the manifest-path must be a path \
to a Cargo.toml file",
),
);
).run();
}

fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) {
Expand All @@ -26,16 +24,15 @@ fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) {
.collect::<Vec<_>>()
.join("[..]");

assert_that(
p.cargo(command)
.arg("--manifest-path")
.arg(manifest_path_argument)
.cwd(p.root().parent().unwrap()),
execs().with_status(101).with_stderr(format!(
p.cargo(command)
.arg("--manifest-path")
.arg(manifest_path_argument)
.cwd(p.root().parent().unwrap())
.with_status(101)
.with_stderr(format!(
"[ERROR] manifest path `{}` does not exist",
expected_path
)),
);
)).run();
}

#[test]
Expand Down Expand Up @@ -325,14 +322,13 @@ fn verify_project_dir_containing_cargo_toml() {
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.build();

assert_that(
p.cargo("verify-project --manifest-path foo")
.cwd(p.root().parent().unwrap()),
execs().with_status(1).with_stdout(
p.cargo("verify-project --manifest-path foo")
.cwd(p.root().parent().unwrap())
.with_status(1)
.with_stdout(
"{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\
",
),
);
).run();
}

#[test]
Expand All @@ -342,14 +338,13 @@ fn verify_project_dir_plus_file() {
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.build();

assert_that(
p.cargo("verify-project --manifest-path foo/bar")
.cwd(p.root().parent().unwrap()),
execs().with_status(1).with_stdout(
p.cargo("verify-project --manifest-path foo/bar")
.cwd(p.root().parent().unwrap())
.with_status(1)
.with_stdout(
"{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\
",
),
);
).run();
}

#[test]
Expand All @@ -359,25 +354,23 @@ fn verify_project_dir_plus_path() {
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.build();

assert_that(
p.cargo("verify-project --manifest-path foo/bar/baz")
.cwd(p.root().parent().unwrap()),
execs().with_status(1).with_stdout(
p.cargo("verify-project --manifest-path foo/bar/baz")
.cwd(p.root().parent().unwrap())
.with_status(1)
.with_stdout(
"{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\
",
),
);
).run();
}

#[test]
fn verify_project_dir_to_nonexistent_cargo_toml() {
let p = project().build();
assert_that(
p.cargo("verify-project --manifest-path foo/bar/baz/Cargo.toml")
.cwd(p.root().parent().unwrap()),
execs().with_status(1).with_stdout(
p.cargo("verify-project --manifest-path foo/bar/baz/Cargo.toml")
.cwd(p.root().parent().unwrap())
.with_status(1)
.with_stdout(
"{\"invalid\":\"manifest path `foo[..]bar[..]baz[..]Cargo.toml` does not exist\"}\
",
),
);
).run();
}
Loading

0 comments on commit 85984a8

Please sign in to comment.