nushell/tests/filter_inc_tests.rs

136 lines
3.4 KiB
Rust
Raw Normal View History

2019-08-10 10:54:49 +02:00
mod helpers;
2019-08-10 11:12:48 +02:00
use h::{in_directory as cwd, Playground, Stub::*};
use helpers as h;
2019-08-10 10:54:49 +02:00
#[test]
2019-08-10 11:12:48 +02:00
fn can_only_apply_one() {
nu_error!(
2019-08-10 10:54:49 +02:00
output,
cwd("tests/fixtures/formats"),
2019-08-10 11:12:48 +02:00
"open cargo_sample.toml | first 1 | inc package.version --major --minor"
2019-08-10 10:54:49 +02:00
);
2019-08-10 11:12:48 +02:00
assert!(output.contains("Usage: inc field [--major|--minor|--patch]"));
2019-08-10 10:54:49 +02:00
}
#[test]
2019-08-14 22:55:26 +02:00
fn by_one_with_field_passed() {
Playground::setup_for("plugin_inc_by_one_with_field_passed_test")
2019-08-10 11:12:48 +02:00
.with_files(vec![FileWithContent(
"sample.toml",
r#"
[package]
edition = "2018"
"#,
)]);
2019-08-10 10:54:49 +02:00
nu!(
output,
2019-08-14 22:55:26 +02:00
cwd("tests/fixtures/nuplayground/plugin_inc_by_one_with_field_passed_test"),
2019-08-10 11:12:48 +02:00
"open sample.toml | inc package.edition | get package.edition | echo $it"
2019-08-10 10:54:49 +02:00
);
assert_eq!(output, "2019");
}
2019-08-14 22:55:26 +02:00
#[test]
fn by_one_with_no_field_passed() {
Playground::setup_for("plugin_inc_by_one_with_no_field_passed_test")
.with_files(vec![FileWithContent(
"sample.toml",
r#"
[package]
contributors = "2"
"#,
)]);
nu!(
output,
cwd("tests/fixtures/nuplayground/plugin_inc_by_one_with_no_field_passed_test"),
"open sample.toml | get package.contributors | inc | echo $it"
);
assert_eq!(output, "3");
}
2019-08-10 10:54:49 +02:00
#[test]
fn semversion_major_inc() {
Playground::setup_for("plugin_inc_major_semversion_test")
2019-08-10 11:12:48 +02:00
.with_files(vec![FileWithContent(
"sample.toml",
r#"
[package]
version = "0.1.3"
"#,
)]);
2019-08-10 10:54:49 +02:00
nu!(
output,
cwd("tests/fixtures/nuplayground/plugin_inc_major_semversion_test"),
2019-08-10 11:12:48 +02:00
"open sample.toml | inc package.version --major | get package.version | echo $it"
2019-08-10 10:54:49 +02:00
);
2019-08-10 11:12:48 +02:00
assert_eq!(output, "1.0.0");
2019-08-10 10:54:49 +02:00
}
#[test]
fn semversion_minor_inc() {
Playground::setup_for("plugin_inc_minor_semversion_test")
2019-08-10 11:12:48 +02:00
.with_files(vec![FileWithContent(
"sample.toml",
r#"
[package]
version = "0.1.3"
"#,
)]);
2019-08-10 10:54:49 +02:00
nu!(
output,
cwd("tests/fixtures/nuplayground/plugin_inc_minor_semversion_test"),
"open sample.toml | inc package.version --minor | get package.version | echo $it"
);
assert_eq!(output, "0.2.0");
}
#[test]
fn semversion_patch_inc() {
Playground::setup_for("plugin_inc_patch_semversion_test")
.with_files(vec![FileWithContent(
"sample.toml",
r#"
[package]
version = "0.1.3"
"#,
)]);
nu!(
output,
cwd("tests/fixtures/nuplayground/plugin_inc_patch_semversion_test"),
"open sample.toml | inc package.version --patch | get package.version | echo $it"
);
assert_eq!(output, "0.1.4");
}
#[test]
fn semversion_without_passing_field() {
Playground::setup_for("plugin_inc_semversion_without_passing_field_test")
.with_files(vec![FileWithContent(
"sample.toml",
r#"
[package]
version = "0.1.3"
"#,
)]);
nu!(
output,
cwd("tests/fixtures/nuplayground/plugin_inc_semversion_without_passing_field_test"),
2019-08-10 11:12:48 +02:00
"open sample.toml | get package.version | inc --patch | echo $it"
2019-08-10 10:54:49 +02:00
);
2019-08-10 11:12:48 +02:00
assert_eq!(output, "0.1.4");
2019-08-10 10:54:49 +02:00
}