mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 19:57:52 +02:00
Clean up.
This commit is contained in:
@ -1,29 +1,7 @@
|
||||
mod helpers;
|
||||
|
||||
use helpers::in_directory as cwd;
|
||||
|
||||
#[test]
|
||||
fn regular_field_by_one() {
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
"open cargo_sample.toml | inc package.edition | get package.edition | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "2019");
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn by_one_without_passing_field() {
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
"open cargo_sample.toml | get package.edition | inc | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "2019");
|
||||
}
|
||||
use h::{in_directory as cwd, Playground, Stub::*};
|
||||
use helpers as h;
|
||||
|
||||
#[test]
|
||||
fn can_only_apply_one() {
|
||||
@ -37,34 +15,82 @@ fn can_only_apply_one() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semversion_major() {
|
||||
fn regular_field_by_one() {
|
||||
Playground::setup_for("plugin_inc_test_1")
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
edition = "2018"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
"open cargo_sample.toml | inc package.version --major | get package.version | echo $it"
|
||||
cwd("tests/fixtures/nuplayground/plugin_inc_test_1"),
|
||||
"open sample.toml | inc package.edition | get package.edition | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "2019");
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn by_one_without_passing_field() {
|
||||
Playground::setup_for("plugin_inc_test_2")
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
contributors = "2"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/nuplayground/plugin_inc_test_2"),
|
||||
"open sample.toml | get package.contributors | inc | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semversion() {
|
||||
Playground::setup_for("plugin_inc_test_3")
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
version = "0.1.3"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/nuplayground/plugin_inc_test_3"),
|
||||
"open sample.toml | inc package.version --major | get package.version | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "1.0.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semversion_minor() {
|
||||
fn semversion_without_passing_field() {
|
||||
Playground::setup_for("plugin_inc_test_4")
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
version = "0.1.3"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
"open cargo_sample.toml | inc package.version --minor | get package.version | echo $it"
|
||||
cwd("tests/fixtures/nuplayground/plugin_inc_test_4"),
|
||||
"open sample.toml | get package.version | inc --patch | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "0.2.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semversion_patch() {
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
"open cargo_sample.toml | inc package.version --patch | get package.version | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "0.1.2");
|
||||
assert_eq!(output, "0.1.4");
|
||||
}
|
@ -1,20 +1,10 @@
|
||||
mod helpers;
|
||||
|
||||
use helpers::in_directory as cwd;
|
||||
use h::{in_directory as cwd, Playground, Stub::*};
|
||||
use helpers as h;
|
||||
|
||||
#[test]
|
||||
fn acts_without_passing_field() {
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
"open caco3_plastics.csv | first 1 | get origin | str --downcase | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "spain");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn str_can_only_apply_one() {
|
||||
fn can_only_apply_one() {
|
||||
nu_error!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
@ -25,22 +15,61 @@ fn str_can_only_apply_one() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn downcases() {
|
||||
fn acts_without_passing_field() {
|
||||
Playground::setup_for("plugin_str_test_without_passing_field")
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.yml",
|
||||
r#"
|
||||
environment:
|
||||
global:
|
||||
PROJECT_NAME: nushell
|
||||
"#,
|
||||
)]);
|
||||
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
"open caco3_plastics.csv | first 1 | str origin --downcase | get origin | echo $it"
|
||||
cwd("tests/fixtures/nuplayground/plugin_str_test_without_passing_field"),
|
||||
"open sample.yml | get environment.global.PROJECT_NAME | str --upcase | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "spain");
|
||||
assert_eq!(output, "NUSHELL");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn downcases() {
|
||||
Playground::setup_for("plugin_str_test_downcases")
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependency]
|
||||
name = "LIGHT"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/nuplayground/plugin_str_test_downcases"),
|
||||
"open sample.toml | str dependency.name --downcase | get dependency.name | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "light");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upcases() {
|
||||
Playground::setup_for("plugin_str_test_upcases")
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "nushell"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
"open appveyor.yml | str environment.global.PROJECT_NAME --upcase | get environment.global.PROJECT_NAME | echo $it"
|
||||
cwd("tests/fixtures/nuplayground/plugin_str_test_upcases"),
|
||||
"open sample.toml | str package.name --upcase | get package.name | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "NUSHELL");
|
||||
@ -51,7 +80,7 @@ fn converts_to_int() {
|
||||
nu!(
|
||||
output,
|
||||
cwd("tests/fixtures/formats"),
|
||||
"open caco3_plastics.csv | get 0 | str tariff_item --to-int | where tariff_item == 2509000000 | get tariff_item | echo $it"
|
||||
"open caco3_plastics.csv | first 1 | str tariff_item --to-int | where tariff_item == 2509000000 | get tariff_item | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(output, "2509000000");
|
||||
|
Reference in New Issue
Block a user