mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 11:55:55 +02:00
Slim down tests (#9021)
This PR just tidies up some tests by removing unused code: 1. If the filesystem is not touched, don't use the filesystem playground/sandbox 2. If the filesystem is not touched, don't specify the `cwd` 3. If the command is short, don't bother wrapping it in `pipeline()` 4. If the command doesn't have quotes, don't bother with a `r#"..."#` raw string Part of #8670.
This commit is contained in:
@ -16,9 +16,7 @@ fn sets_the_column() {
|
||||
|
||||
#[test]
|
||||
fn doesnt_convert_record_to_table() {
|
||||
let actual = nu!(
|
||||
cwd: ".", r#"{a:1} | update a 2 | to nuon"#
|
||||
);
|
||||
let actual = nu!("{a:1} | update a 2 | to nuon");
|
||||
|
||||
assert_eq!(actual.out, "{a: 2}");
|
||||
}
|
||||
@ -83,44 +81,27 @@ fn upsert_column_missing() {
|
||||
|
||||
#[test]
|
||||
fn update_list() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
[1, 2, 3] | update 1 abc | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
let actual = nu!("[1, 2, 3] | update 1 abc | to json -r");
|
||||
assert_eq!(actual.out, r#"[1,"abc",3]"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn update_past_end_list() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
[1, 2, 3] | update 5 abc | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
let actual = nu!("[1, 2, 3] | update 5 abc | to json -r");
|
||||
assert!(actual.err.contains("too large"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn update_nonexistent_column() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"{a:1} | update b 2"#
|
||||
));
|
||||
|
||||
let actual = nu!("{a:1} | update b 2");
|
||||
assert!(actual.err.contains("cannot find column 'b'"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn update_uses_enumerate_index() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"[[a]; [7] [6]] | enumerate | update item.a {|el| $el.index + 1 + $el.item.a } | flatten | to nuon"#
|
||||
));
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[[index, a]; [0, 8], [1, 8]]");
|
||||
}
|
||||
|
Reference in New Issue
Block a user