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-10 11:12:48 +02:00
|
|
|
fn regular_field_by_one() {
|
|
|
|
Playground::setup_for("plugin_inc_test_1")
|
|
|
|
.with_files(vec![FileWithContent(
|
|
|
|
"sample.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
edition = "2018"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
2019-08-10 10:54:49 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-08-10 11:12:48 +02:00
|
|
|
cwd("tests/fixtures/nuplayground/plugin_inc_test_1"),
|
|
|
|
"open sample.toml | inc package.edition | get package.edition | echo $it"
|
2019-08-10 10:54:49 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(output, "2019");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
2019-08-10 11:12:48 +02:00
|
|
|
fn by_one_without_passing_field() {
|
|
|
|
Playground::setup_for("plugin_inc_test_2")
|
|
|
|
.with_files(vec![FileWithContent(
|
|
|
|
"sample.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
contributors = "2"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
2019-08-10 10:54:49 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-08-10 11:12:48 +02:00
|
|
|
cwd("tests/fixtures/nuplayground/plugin_inc_test_2"),
|
|
|
|
"open sample.toml | get package.contributors | inc | echo $it"
|
2019-08-10 10:54:49 +02:00
|
|
|
);
|
|
|
|
|
2019-08-10 11:12:48 +02:00
|
|
|
assert_eq!(output, "3");
|
2019-08-10 10:54:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2019-08-10 13:04:13 +02:00
|
|
|
fn semversion_major_inc() {
|
2019-08-10 11:12:48 +02:00
|
|
|
Playground::setup_for("plugin_inc_test_3")
|
|
|
|
.with_files(vec![FileWithContent(
|
|
|
|
"sample.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
version = "0.1.3"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
2019-08-10 10:54:49 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-08-10 11:12:48 +02:00
|
|
|
cwd("tests/fixtures/nuplayground/plugin_inc_test_3"),
|
|
|
|
"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]
|
2019-08-10 13:04:13 +02:00
|
|
|
fn semversion_minor_inc() {
|
2019-08-10 11:12:48 +02:00
|
|
|
Playground::setup_for("plugin_inc_test_4")
|
|
|
|
.with_files(vec![FileWithContent(
|
|
|
|
"sample.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
version = "0.1.3"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
2019-08-10 10:54:49 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-08-10 11:12:48 +02:00
|
|
|
cwd("tests/fixtures/nuplayground/plugin_inc_test_4"),
|
2019-08-10 13:04:13 +02:00
|
|
|
"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_test_5")
|
|
|
|
.with_files(vec![FileWithContent(
|
|
|
|
"sample.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
version = "0.1.3"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
nu!(
|
|
|
|
output,
|
|
|
|
cwd("tests/fixtures/nuplayground/plugin_inc_test_5"),
|
|
|
|
"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_test_6")
|
|
|
|
.with_files(vec![FileWithContent(
|
|
|
|
"sample.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
version = "0.1.3"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
nu!(
|
|
|
|
output,
|
|
|
|
cwd("tests/fixtures/nuplayground/plugin_inc_test_6"),
|
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
|
|
|
}
|