Skip to content

Commit 9d164aa

Browse files
committed
test: migrate all test from cargo-information
1 parent c76c8fd commit 9d164aa

File tree

188 files changed

+4076
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+4076
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use cargo_test_support::file;
2+
use cargo_test_support::prelude::*;
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+
45+
snapbox::cmd::Command::cargo_ui()
46+
.arg("info")
47+
.arg("my-package")
48+
.arg("--registry=dummy-registry")
49+
.assert()
50+
.success()
51+
.stdout_eq(file!["stdout.term.svg"])
52+
.stderr_eq(file!["stderr.term.svg"]);
53+
}
Lines changed: 31 additions & 0 deletions
Loading
Lines changed: 51 additions & 0 deletions
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use cargo_test_support::file;
2+
use cargo_test_support::prelude::*;
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.1")
10+
.feature("default", &["feature1", "feature2"])
11+
.feature("feature1", &[])
12+
.feature("feature2", &[])
13+
.publish();
14+
15+
snapbox::cmd::Command::cargo_ui()
16+
.arg("info")
17+
.arg("my-package")
18+
.arg("--registry=dummy-registry")
19+
.assert()
20+
.success()
21+
.stdout_eq(file!["stdout.term.svg"])
22+
.stderr_eq(file!["stderr.term.svg"]);
23+
}
Lines changed: 31 additions & 0 deletions
Loading
Lines changed: 44 additions & 0 deletions
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use cargo_test_support::file;
2+
use cargo_test_support::prelude::*;
3+
4+
use super::init_registry_without_token;
5+
6+
#[cargo_test]
7+
fn case() {
8+
const MANY_FEATURES_COUNT: usize = 200;
9+
const DEFAULT_FEATURES_COUNT: usize = 100;
10+
11+
init_registry_without_token();
12+
let mut test_package =
13+
cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package");
14+
let features = (0..MANY_FEATURES_COUNT)
15+
.map(|i| format!("eyes{i:03}"))
16+
.collect::<Vec<_>>();
17+
for name in &features {
18+
test_package.feature(name.as_str(), &[]);
19+
}
20+
let default_features = features
21+
.iter()
22+
.take(DEFAULT_FEATURES_COUNT)
23+
.map(|s| s.as_str())
24+
.collect::<Vec<_>>();
25+
test_package.feature("default", &default_features);
26+
test_package.publish();
27+
28+
snapbox::cmd::Command::cargo_ui()
29+
.arg("info")
30+
.arg("your-face")
31+
.arg("--registry=dummy-registry")
32+
.assert()
33+
.success()
34+
.stdout_eq(file!["stdout.term.svg"])
35+
.stderr_eq(file!["stderr.term.svg"]);
36+
}
Lines changed: 31 additions & 0 deletions
Loading
Lines changed: 43 additions & 0 deletions
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use cargo_test_support::file;
2+
use cargo_test_support::prelude::*;
3+
4+
use super::init_registry_without_token;
5+
6+
#[cargo_test]
7+
fn case() {
8+
const MANY_FEATURES_COUNT: usize = 200;
9+
const DEFAULT_FEATURES_COUNT: usize = 100;
10+
11+
init_registry_without_token();
12+
let mut test_package =
13+
cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package");
14+
let features = (0..MANY_FEATURES_COUNT)
15+
.map(|i| format!("eyes{i:03}"))
16+
.collect::<Vec<_>>();
17+
for name in &features {
18+
test_package.feature(name.as_str(), &[]);
19+
}
20+
let default_features = features
21+
.iter()
22+
.take(DEFAULT_FEATURES_COUNT)
23+
.map(|s| s.as_str())
24+
.collect::<Vec<_>>();
25+
test_package.feature("default", &default_features);
26+
test_package.publish();
27+
28+
snapbox::cmd::Command::cargo_ui()
29+
.arg("info")
30+
.arg("your-face")
31+
.arg("--verbose")
32+
.arg("--registry=dummy-registry")
33+
.assert()
34+
.success()
35+
.stdout_eq(file!["stdout.term.svg"])
36+
.stderr_eq(file!["stderr.term.svg"]);
37+
}

0 commit comments

Comments
 (0)