Skip to content

Commit

Permalink
test: migrate all test from cargo-information
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Aug 10, 2024
1 parent c76c8fd commit 9d164aa
Show file tree
Hide file tree
Showing 188 changed files with 4,076 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/testsuite/cargo_info/basic/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use cargo_test_support::file;
use cargo_test_support::prelude::*;

use super::init_registry_without_token;

#[cargo_test]
fn case() {
init_registry_without_token();
cargo_test_support::registry::Package::new("my-package", "0.1.0")
.file(
"Cargo.toml",
r#"
[package]
name = "my-package"
version = "0.1.0"
description = "A package for testing"
repository = "https://github.com/hi-rustin/cargo-infromation"
documentation = "https://docs.rs/my-package/0.1.0"
license = "MIT"
edition = "2018"
rust-version = "1.50.0"
keywords = ["foo", "bar", "baz"]
[features]
default = ["feature1"]
feature1 = []
feature2 = []
[dependencies]
foo = "0.1.0"
bar = "0.2.0"
baz = { version = "0.3.0", optional = true }
[[bin]]
name = "my_bin"
[lib]
name = "my_lib"
"#,
)
.file("src/bin/my_bin.rs", "")
.file("src/lib.rs", "")
.publish();

snapbox::cmd::Command::cargo_ui()
.arg("info")
.arg("my-package")
.arg("--registry=dummy-registry")
.assert()
.success()
.stdout_eq(file!["stdout.term.svg"])
.stderr_eq(file!["stderr.term.svg"]);
}
31 changes: 31 additions & 0 deletions tests/testsuite/cargo_info/basic/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions tests/testsuite/cargo_info/basic/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions tests/testsuite/cargo_info/features/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use cargo_test_support::file;
use cargo_test_support::prelude::*;

use super::init_registry_without_token;

#[cargo_test]
fn case() {
init_registry_without_token();
cargo_test_support::registry::Package::new("my-package", "0.1.1")
.feature("default", &["feature1", "feature2"])
.feature("feature1", &[])
.feature("feature2", &[])
.publish();

snapbox::cmd::Command::cargo_ui()
.arg("info")
.arg("my-package")
.arg("--registry=dummy-registry")
.assert()
.success()
.stdout_eq(file!["stdout.term.svg"])
.stderr_eq(file!["stderr.term.svg"]);
}
31 changes: 31 additions & 0 deletions tests/testsuite/cargo_info/features/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions tests/testsuite/cargo_info/features/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions tests/testsuite/cargo_info/features_activated_over_limit/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use cargo_test_support::file;
use cargo_test_support::prelude::*;

use super::init_registry_without_token;

#[cargo_test]
fn case() {
const MANY_FEATURES_COUNT: usize = 200;
const DEFAULT_FEATURES_COUNT: usize = 100;

init_registry_without_token();
let mut test_package =
cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package");
let features = (0..MANY_FEATURES_COUNT)
.map(|i| format!("eyes{i:03}"))
.collect::<Vec<_>>();
for name in &features {
test_package.feature(name.as_str(), &[]);
}
let default_features = features
.iter()
.take(DEFAULT_FEATURES_COUNT)
.map(|s| s.as_str())
.collect::<Vec<_>>();
test_package.feature("default", &default_features);
test_package.publish();

snapbox::cmd::Command::cargo_ui()
.arg("info")
.arg("your-face")
.arg("--registry=dummy-registry")
.assert()
.success()
.stdout_eq(file!["stdout.term.svg"])
.stderr_eq(file!["stderr.term.svg"]);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use cargo_test_support::file;
use cargo_test_support::prelude::*;

use super::init_registry_without_token;

#[cargo_test]
fn case() {
const MANY_FEATURES_COUNT: usize = 200;
const DEFAULT_FEATURES_COUNT: usize = 100;

init_registry_without_token();
let mut test_package =
cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package");
let features = (0..MANY_FEATURES_COUNT)
.map(|i| format!("eyes{i:03}"))
.collect::<Vec<_>>();
for name in &features {
test_package.feature(name.as_str(), &[]);
}
let default_features = features
.iter()
.take(DEFAULT_FEATURES_COUNT)
.map(|s| s.as_str())
.collect::<Vec<_>>();
test_package.feature("default", &default_features);
test_package.publish();

snapbox::cmd::Command::cargo_ui()
.arg("info")
.arg("your-face")
.arg("--verbose")
.arg("--registry=dummy-registry")
.assert()
.success()
.stdout_eq(file!["stdout.term.svg"])
.stderr_eq(file!["stderr.term.svg"]);
}
Loading

0 comments on commit 9d164aa

Please sign in to comment.