2020-01-10 15:44:24 +00:00
|
|
|
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
|
|
use nu_test_support::playground::Playground;
|
2019-12-17 18:54:39 +00:00
|
|
|
use nu_test_support::{nu, pipeline};
|
2019-12-15 16:15:06 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn adds_a_row_to_the_beginning() {
|
2020-01-10 15:44:24 +00:00
|
|
|
Playground::setup("prepend_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"los_tres_caballeros.txt",
|
|
|
|
r#"
|
|
|
|
Andrés N. Robalino
|
|
|
|
Jonathan Turner
|
|
|
|
Yehuda Katz
|
|
|
|
"#,
|
|
|
|
)]);
|
2019-12-15 16:15:06 +00:00
|
|
|
|
2020-01-10 15:44:24 +00:00
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), pipeline(
|
|
|
|
r#"
|
|
|
|
open los_tres_caballeros.txt
|
|
|
|
| lines
|
|
|
|
| prepend "pollo loco"
|
2022-02-09 10:58:54 +00:00
|
|
|
| get 0
|
2020-01-10 15:44:24 +00:00
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2020-05-07 11:03:43 +00:00
|
|
|
assert_eq!(actual.out, "pollo loco");
|
2020-01-10 15:44:24 +00:00
|
|
|
})
|
2019-12-15 16:15:06 +00:00
|
|
|
}
|
last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623)
Closes https://github.com/nushell/nushell/issues/6941
2022-12-31 11:35:12 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn fail_on_non_iterator() {
|
|
|
|
let actual = nu!(cwd: ".", pipeline("1 | prepend 4"));
|
|
|
|
|
|
|
|
assert!(actual.err.contains("only_supports_this_input_type"));
|
|
|
|
}
|