Skip to content

Commit

Permalink
Add test for empty dep table error
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Apr 19, 2023
1 parent 7399c27 commit 3751c54
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/testsuite/cargo_add/add-basic.in/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
your-face = { }
1 change: 1 addition & 0 deletions tests/testsuite/cargo_add/empty_dep_table/in
25 changes: 25 additions & 0 deletions tests/testsuite/cargo_add/empty_dep_table/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("add")
.arg_line("your-face --features eyes")
.current_dir(cwd)
.assert()
.code(101)
.stdout_matches_path(curr_dir!().join("stdout.log"))
.stderr_matches_path(curr_dir!().join("stderr.log"));

assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
}
8 changes: 8 additions & 0 deletions tests/testsuite/cargo_add/empty_dep_table/out/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[workspace]

[package]
name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
your-face = { }
1 change: 1 addition & 0 deletions tests/testsuite/cargo_add/empty_dep_table/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error: Unrecognized dependency source for `your-face`, expected a table with a `version`, `git`, `path`, or `workspace` key
Empty file.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod dev;
mod dev_build_conflict;
mod dev_prefer_existing_version;
mod dry_run;
mod empty_dep_table;
mod features;
mod features_empty;
mod features_multiple_occurrences;
Expand Down

0 comments on commit 3751c54

Please sign in to comment.