Skip to content

Commit d371702

Browse files
committed
test(cargo-info): rename underscore test to crate_name_normalization and added underscore to hyphen check
1 parent fc31de1 commit d371702

7 files changed

Lines changed: 149 additions & 54 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
use crate::prelude::*;
2+
use cargo_test_support::file;
3+
4+
use super::init_registry_without_token;
5+
6+
#[cargo_test]
7+
fn case() {
8+
init_registry_without_token();
9+
cargo_test_support::registry::Package::new("my-package", "0.1.0")
10+
.file(
11+
"Cargo.toml",
12+
r#"
13+
[package]
14+
name = "my-package"
15+
version = "0.1.0"
16+
description = "A package for testing"
17+
repository = "https://github.com/hi-rustin/cargo-infromation"
18+
documentation = "https://docs.rs/my-package/0.1.0"
19+
license = "MIT"
20+
edition = "2018"
21+
rust-version = "1.50.0"
22+
keywords = ["foo", "bar", "baz"]
23+
24+
[features]
25+
default = ["feature1"]
26+
feature1 = []
27+
feature2 = []
28+
29+
[dependencies]
30+
foo = "0.1.0"
31+
bar = "0.2.0"
32+
baz = { version = "0.3.0", optional = true }
33+
34+
[[bin]]
35+
name = "my_bin"
36+
37+
[lib]
38+
name = "my_lib"
39+
"#,
40+
)
41+
.file("src/bin/my_bin.rs", "")
42+
.file("src/lib.rs", "")
43+
.publish();
44+
cargo_test_support::registry::Package::new("my_crate", "0.1.0")
45+
.file(
46+
"Cargo.toml",
47+
r#"
48+
[package]
49+
name = "my_crate"
50+
version = "0.1.0"
51+
description = "A package for testing"
52+
repository = "https://github.com/hi-rustin/cargo-infromation"
53+
documentation = "https://docs.rs/my-package/0.1.0"
54+
license = "MIT"
55+
edition = "2018"
56+
rust-version = "1.50.0"
57+
keywords = ["foo", "bar", "baz"]
58+
59+
[features]
60+
default = ["feature1"]
61+
feature1 = []
62+
feature2 = []
63+
64+
[dependencies]
65+
foo = "0.1.0"
66+
bar = "0.2.0"
67+
baz = { version = "0.3.0", optional = true }
68+
69+
[[bin]]
70+
name = "my_bin"
71+
72+
[lib]
73+
name = "my_lib"
74+
"#,
75+
)
76+
.file("src/bin/my_bin.rs", "")
77+
.file("src/lib.rs", "")
78+
.publish();
79+
80+
snapbox::cmd::Command::cargo_ui()
81+
.arg("info")
82+
.arg("my_package") //underscore on purpose to show the error
83+
.arg("--registry=dummy-registry")
84+
.assert()
85+
.failure()
86+
.stdout_eq(file!["stdout1.term.svg"])
87+
.stderr_eq(file!["stderr1.term.svg"]);
88+
89+
snapbox::cmd::Command::cargo_ui()
90+
.arg("info")
91+
.arg("my-crate") //hyphen on purpose to show the error
92+
.arg("--registry=dummy-registry")
93+
.assert()
94+
.failure()
95+
.stdout_eq(file!["stdout2.term.svg"])
96+
.stderr_eq(file!["stderr2.term.svg"]);
97+
}

tests/testsuite/cargo_info/underscore_alias/stderr.term.svg renamed to tests/testsuite/cargo_info/crate_name_normalization/stderr1.term.svg

File renamed without changes.
Lines changed: 30 additions & 0 deletions
Loading

tests/testsuite/cargo_info/underscore_alias/stdout.term.svg renamed to tests/testsuite/cargo_info/crate_name_normalization/stdout1.term.svg

File renamed without changes.
Lines changed: 21 additions & 0 deletions
Loading

tests/testsuite/cargo_info/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
mod basic;
2+
mod crate_name_normalization;
23
mod features;
34
mod features_activated_over_limit;
45
mod features_activated_over_limit_verbose;
@@ -16,7 +17,6 @@ mod specify_version_with_url_but_registry_is_not_matched;
1617
mod specify_version_within_ws_and_conflict_with_lockfile;
1718
mod specify_version_within_ws_and_match_with_lockfile;
1819
mod transitive_dependency_within_ws;
19-
mod underscore_alias;
2020
mod verbose;
2121
mod with_default_registry_configured;
2222
mod with_default_registry_configured_and_specified;

tests/testsuite/cargo_info/underscore_alias/mod.rs

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)