mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 17:43:12 +02:00
Pick->Select rename. Integration tests changes. (#1725)
Pick->Select rename. Integration tests changes.
This commit is contained in:
committed by
GitHub
parent
c3efdf2689
commit
96e5fc05a3
@ -1,15 +1,17 @@
|
||||
use nu_test_support::fs::Stub::FileWithContent;
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, nu_error};
|
||||
|
||||
#[test]
|
||||
fn can_only_apply_one() {
|
||||
let actual = nu_error!(
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"open cargo_sample.toml | first 1 | inc package.version --major --minor"
|
||||
);
|
||||
|
||||
assert!(actual.contains("Usage: inc field [--major|--minor|--patch]"));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Usage: inc field [--major|--minor|--patch]"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -28,7 +30,7 @@ fn by_one_with_field_passed() {
|
||||
"open sample.toml | inc package.edition | get package.edition | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "2019");
|
||||
assert_eq!(actual.out, "2019");
|
||||
})
|
||||
}
|
||||
|
||||
@ -48,7 +50,7 @@ fn by_one_with_no_field_passed() {
|
||||
"open sample.toml | get package.contributors | inc | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "3");
|
||||
assert_eq!(actual.out, "3");
|
||||
})
|
||||
}
|
||||
|
||||
@ -68,7 +70,7 @@ fn semversion_major_inc() {
|
||||
"open sample.toml | inc package.version -M | get package.version | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "1.0.0");
|
||||
assert_eq!(actual.out, "1.0.0");
|
||||
})
|
||||
}
|
||||
|
||||
@ -88,7 +90,7 @@ fn semversion_minor_inc() {
|
||||
"open sample.toml | inc package.version --minor | get package.version | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "0.2.0");
|
||||
assert_eq!(actual.out, "0.2.0");
|
||||
})
|
||||
}
|
||||
|
||||
@ -108,7 +110,7 @@ fn semversion_patch_inc() {
|
||||
"open sample.toml | inc package.version --patch | get package.version | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "0.1.4");
|
||||
assert_eq!(actual.out, "0.1.4");
|
||||
})
|
||||
}
|
||||
|
||||
@ -128,6 +130,6 @@ fn semversion_without_passing_field() {
|
||||
"open sample.toml | get package.version | inc --patch | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "0.1.4");
|
||||
assert_eq!(actual.out, "0.1.4");
|
||||
})
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
use nu_test_support::fs::Stub::FileWithContent;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, nu_error, pipeline};
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn can_only_apply_one() {
|
||||
let actual = nu_error!(
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"open caco3_plastics.csv | first 1 | str origin --downcase --upcase"
|
||||
);
|
||||
|
||||
assert!(actual.contains(r#"--capitalize|--downcase|--upcase|--to-int|--substring "start,end"|--replace|--find-replace [pattern replacement]|to-date-time|--trim]"#));
|
||||
assert!(actual.err.contains(r#"--capitalize|--downcase|--upcase|--to-int|--substring "start,end"|--replace|--find-replace [pattern replacement]|to-date-time|--trim]"#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -29,7 +29,7 @@ fn acts_without_passing_field() {
|
||||
"open sample.yml | get environment.global.PROJECT_NAME | str --upcase | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "NUSHELL");
|
||||
assert_eq!(actual.out, "NUSHELL");
|
||||
})
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ fn trims() {
|
||||
"open sample.toml | str dependency.name --trim | get dependency.name | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "nu");
|
||||
assert_eq!(actual.out, "nu");
|
||||
})
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ fn capitalizes() {
|
||||
"open sample.toml | str dependency.name --capitalize | get dependency.name | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "Nu");
|
||||
assert_eq!(actual.out, "Nu");
|
||||
})
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ fn downcases() {
|
||||
"open sample.toml | str dependency.name -d | get dependency.name | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "light");
|
||||
assert_eq!(actual.out, "light");
|
||||
})
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ fn upcases() {
|
||||
"open sample.toml | str package.name --upcase | get package.name | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "NUSHELL");
|
||||
assert_eq!(actual.out, "NUSHELL");
|
||||
})
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ fn converts_to_int() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "1");
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -152,7 +152,7 @@ fn replaces() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "wykittenshell");
|
||||
assert_eq!(actual.out, "wykittenshell");
|
||||
})
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ fn find_and_replaces() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "1-800-5289");
|
||||
assert_eq!(actual.out, "1-800-5289");
|
||||
})
|
||||
}
|
||||
|
||||
@ -202,6 +202,6 @@ fn find_and_replaces_without_passing_field() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "1-800-5289");
|
||||
assert_eq!(actual.out, "1-800-5289");
|
||||
})
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
use nu_test_support::{nu, nu_error};
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn shows_error_for_command_not_found() {
|
||||
let actual = nu_error!(
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"ferris_is_not_here.exe"
|
||||
);
|
||||
|
||||
assert!(actual.contains("Command not found"));
|
||||
assert!(actual.err.contains("Command not found"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -25,7 +25,7 @@ fn automatically_change_directory() {
|
||||
"#
|
||||
);
|
||||
|
||||
assert!(actual.ends_with("autodir"));
|
||||
assert!(actual.out.ends_with("autodir"));
|
||||
})
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ fn automatically_change_directory_with_trailing_slash_and_same_name_as_command()
|
||||
"#
|
||||
);
|
||||
|
||||
assert!(actual.ends_with("cd"));
|
||||
assert!(actual.out.ends_with("cd"));
|
||||
})
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ fn automatically_change_directory_with_trailing_slash_and_same_name_as_command()
|
||||
fn correctly_escape_external_arguments() {
|
||||
let actual = nu!(cwd: ".", r#"^echo '$0'"#);
|
||||
|
||||
assert_eq!(actual, "$0");
|
||||
assert_eq!(actual.out, "$0");
|
||||
}
|
||||
|
||||
mod it_evaluation {
|
||||
@ -81,7 +81,7 @@ mod it_evaluation {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "jonathan_likes_cake.txt");
|
||||
assert_eq!(actual.out, "jonathan_likes_cake.txt");
|
||||
})
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ mod it_evaluation {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "AndrásWithKitKat");
|
||||
assert_eq!(actual.out, "AndrásWithKitKat");
|
||||
})
|
||||
}
|
||||
|
||||
@ -131,18 +131,18 @@ mod it_evaluation {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "zion");
|
||||
assert_eq!(actual.out, "zion");
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
mod stdin_evaluation {
|
||||
use super::{nu, nu_error};
|
||||
use super::nu;
|
||||
use nu_test_support::pipeline;
|
||||
|
||||
#[test]
|
||||
fn does_not_panic_with_no_newline_in_stream() {
|
||||
let stderr = nu_error!(
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
pipeline(r#"
|
||||
nonu "where's the nuline?"
|
||||
@ -150,7 +150,7 @@ mod stdin_evaluation {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(stderr, "");
|
||||
assert_eq!(actual.err, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -164,7 +164,8 @@ mod stdin_evaluation {
|
||||
| lines
|
||||
| first 1
|
||||
"#
|
||||
));
|
||||
))
|
||||
.out;
|
||||
|
||||
assert_eq!(stdout, "y");
|
||||
}
|
||||
@ -179,7 +180,7 @@ mod external_words {
|
||||
cococo joturner@foo.bar.baz
|
||||
"#);
|
||||
|
||||
assert_eq!(actual, "joturner@foo.bar.baz");
|
||||
assert_eq!(actual.out, "joturner@foo.bar.baz");
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,7 +193,7 @@ mod nu_commands {
|
||||
nu -c "echo 'foo'"
|
||||
"#);
|
||||
|
||||
assert_eq!(actual, "foo");
|
||||
assert_eq!(actual.out, "foo");
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +206,7 @@ mod nu_script {
|
||||
nu script.nu
|
||||
"#);
|
||||
|
||||
assert_eq!(actual, "done");
|
||||
assert_eq!(actual.out, "done");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -214,7 +215,7 @@ mod nu_script {
|
||||
nu script_multiline.nu
|
||||
"#);
|
||||
|
||||
assert_eq!(actual, "23");
|
||||
assert_eq!(actual.out, "23");
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,8 +232,8 @@ mod tilde_expansion {
|
||||
);
|
||||
|
||||
assert!(
|
||||
!actual.contains('~'),
|
||||
format!("'{}' should not contain ~", actual)
|
||||
!actual.out.contains('~'),
|
||||
format!("'{}' should not contain ~", actual.out)
|
||||
);
|
||||
}
|
||||
|
||||
@ -245,6 +246,6 @@ mod tilde_expansion {
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "1~1");
|
||||
assert_eq!(actual.out, "1~1");
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "AndKitKat");
|
||||
assert_eq!(actual.out, "AndKitKat");
|
||||
})
|
||||
}
|
||||
|
||||
@ -39,11 +39,11 @@ fn can_process_one_row_from_internal_and_pipes_it_to_stdin_of_external() {
|
||||
r#"echo "nushelll" | chop"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "nushell");
|
||||
assert_eq!(actual.out, "nushell");
|
||||
}
|
||||
|
||||
mod parse {
|
||||
use nu_test_support::nu_error;
|
||||
use nu_test_support::nu;
|
||||
|
||||
/*
|
||||
The debug command's signature is:
|
||||
@ -58,49 +58,49 @@ mod parse {
|
||||
|
||||
#[test]
|
||||
fn errors_if_flag_passed_is_not_exact() {
|
||||
let actual = nu_error!(cwd: ".", "debug -ra");
|
||||
let actual = nu!(cwd: ".", "debug -ra");
|
||||
|
||||
assert!(
|
||||
actual.contains("unexpected flag"),
|
||||
actual.err.contains("unexpected flag"),
|
||||
format!(
|
||||
"error message '{}' should contain 'unexpected flag'",
|
||||
actual
|
||||
actual.err
|
||||
)
|
||||
);
|
||||
|
||||
let actual = nu_error!(cwd: ".", "debug --rawx");
|
||||
let actual = nu!(cwd: ".", "debug --rawx");
|
||||
|
||||
assert!(
|
||||
actual.contains("unexpected flag"),
|
||||
actual.err.contains("unexpected flag"),
|
||||
format!(
|
||||
"error message '{}' should contain 'unexpected flag'",
|
||||
actual
|
||||
actual.err
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn errors_if_flag_is_not_supported() {
|
||||
let actual = nu_error!(cwd: ".", "debug --ferris");
|
||||
let actual = nu!(cwd: ".", "debug --ferris");
|
||||
|
||||
assert!(
|
||||
actual.contains("unexpected flag"),
|
||||
actual.err.contains("unexpected flag"),
|
||||
format!(
|
||||
"error message '{}' should contain 'unexpected flag'",
|
||||
actual
|
||||
actual.err
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn errors_if_passed_an_unexpected_argument() {
|
||||
let actual = nu_error!(cwd: ".", "debug ferris");
|
||||
let actual = nu!(cwd: ".", "debug ferris");
|
||||
|
||||
assert!(
|
||||
actual.contains("unexpected argument"),
|
||||
actual.err.contains("unexpected argument"),
|
||||
format!(
|
||||
"error message '{}' should contain 'unexpected argument'",
|
||||
actual
|
||||
actual.err
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -122,8 +122,8 @@ mod tilde_expansion {
|
||||
);
|
||||
|
||||
assert!(
|
||||
!actual.contains('~'),
|
||||
format!("'{}' should not contain ~", actual)
|
||||
!actual.out.contains('~'),
|
||||
format!("'{}' should not contain ~", actual.out)
|
||||
);
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ mod tilde_expansion {
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "1~1");
|
||||
assert_eq!(actual.out, "1~1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -157,7 +157,7 @@ mod tilde_expansion {
|
||||
));
|
||||
|
||||
assert_eq!(
|
||||
actual,
|
||||
actual.out,
|
||||
r#"["andres.txt","gedge.txt","jonathan.txt","yehuda.txt"]"#
|
||||
);
|
||||
})
|
||||
|
@ -6,5 +6,5 @@ use nu_test_support::nu;
|
||||
fn doesnt_break_on_utf8() {
|
||||
let actual = nu!(cwd: ".", "echo ö");
|
||||
|
||||
assert_eq!(actual, "ö", "'{}' should contain ö", actual);
|
||||
assert_eq!(actual.out, "ö", "'{}' should contain ö", actual.out);
|
||||
}
|
||||
|
Reference in New Issue
Block a user