Skip to content

Commit

Permalink
move a snapshot/add/ test into testsuite/cargo_add directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Muscraft authored and Hezuikn committed Sep 22, 2022
1 parent 725b14e commit eedeeff
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 22 deletions.
24 changes: 2 additions & 22 deletions tests/testsuite/cargo_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use cargo_test_support::compare::assert;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

mod build_prefer_existing_version;

fn init_registry() {
cargo_test_support::registry::init();
add_registry_packages(false);
Expand Down Expand Up @@ -202,28 +204,6 @@ fn build() {
assert().subset_matches("tests/snapshots/add/build/out", &project_root);
}

#[cargo_test]
fn build_prefer_existing_version() {
init_alt_registry();
let project = Project::from_template("tests/snapshots/add/build_prefer_existing_version/in");
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo()
.arg("add")
.arg_line("cargo-list-test-fixture-dependency --build")
.current_dir(cwd)
.assert()
.success()
.stdout_matches_path("tests/snapshots/add/build_prefer_existing_version/stdout.log")
.stderr_matches_path("tests/snapshots/add/build_prefer_existing_version/stderr.log");

assert().subset_matches(
"tests/snapshots/add/build_prefer_existing_version/out",
&project_root,
);
}

#[cargo_test]
fn default_features() {
init_registry();
Expand Down
28 changes: 28 additions & 0 deletions tests/testsuite/cargo_add/build_prefer_existing_version/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use cargo_test_support::compare::assert;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use crate::cargo_add::init_alt_registry;

#[cargo_test]
fn build_prefer_existing_version() {
init_alt_registry();
let project =
Project::from_template("tests/testsuite/cargo_add/build_prefer_existing_version/in");
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo()
.arg("add")
.arg_line("cargo-list-test-fixture-dependency --build")
.current_dir(cwd)
.assert()
.success()
.stdout_matches_path("tests/testsuite/cargo_add/build_prefer_existing_version/stdout.log")
.stderr_matches_path("tests/testsuite/cargo_add/build_prefer_existing_version/stderr.log");

assert().subset_matches(
"tests/testsuite/cargo_add/build_prefer_existing_version/out",
&project_root,
);
}

0 comments on commit eedeeff

Please sign in to comment.