Skip to content

Commit 3751c54

Browse files
committed
Add test for empty dep table error
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
1 parent 7399c27 commit 3751c54

File tree

7 files changed

+39
-0
lines changed

7 files changed

+39
-0
lines changed

tests/testsuite/cargo_add/add-basic.in/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
[package]
44
name = "cargo-list-test-fixture"
55
version = "0.0.0"
6+
7+
[dependencies]
8+
your-face = { }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../add-basic.in
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use cargo_test_support::compare::assert_ui;
2+
use cargo_test_support::prelude::*;
3+
use cargo_test_support::Project;
4+
5+
use crate::cargo_add::init_registry;
6+
use cargo_test_support::curr_dir;
7+
8+
#[cargo_test]
9+
fn case() {
10+
init_registry();
11+
let project = Project::from_template(curr_dir!().join("in"));
12+
let project_root = project.root();
13+
let cwd = &project_root;
14+
15+
snapbox::cmd::Command::cargo_ui()
16+
.arg("add")
17+
.arg_line("your-face --features eyes")
18+
.current_dir(cwd)
19+
.assert()
20+
.code(101)
21+
.stdout_matches_path(curr_dir!().join("stdout.log"))
22+
.stderr_matches_path(curr_dir!().join("stderr.log"));
23+
24+
assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
3+
[package]
4+
name = "cargo-list-test-fixture"
5+
version = "0.0.0"
6+
7+
[dependencies]
8+
your-face = { }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error: Unrecognized dependency source for `your-face`, expected a table with a `version`, `git`, `path`, or `workspace` key

tests/testsuite/cargo_add/empty_dep_table/stdout.log

Whitespace-only changes.

tests/testsuite/cargo_add/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mod dev;
1515
mod dev_build_conflict;
1616
mod dev_prefer_existing_version;
1717
mod dry_run;
18+
mod empty_dep_table;
1819
mod features;
1920
mod features_empty;
2021
mod features_multiple_occurrences;

0 commit comments

Comments
 (0)