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:
Reilly Wood
2023-04-28 04:25:44 -07:00
committed by GitHub
parent 4c4c1f6147
commit 3076378373
13 changed files with 80 additions and 345 deletions

View File

@ -16,10 +16,7 @@ fn sets_the_column() {
#[test]
fn doesnt_convert_record_to_table() {
let actual = nu!(
cwd: ".", r#"{a:1} | upsert a 2 | to nuon"#
);
let actual = nu!("{a:1} | upsert a 2 | to nuon");
assert_eq!(actual.out, "{a: 2}");
}
@ -80,30 +77,21 @@ fn upsert_uses_enumerate_index_inserting() {
#[test]
fn upsert_uses_enumerate_index_updating() {
let actual = nu!(
cwd: ".", pipeline(
r#"[[a]; [7] [6]] | enumerate | upsert a {|el| $el.index + 1 + $el.item.a } | flatten | to nuon"#
));
let actual = nu!("[[a]; [7] [6]] | enumerate | upsert a {|el| $el.index + 1 + $el.item.a } | flatten | to nuon");
assert_eq!(actual.out, "[[index, a]; [0, 8], [1, 8]]");
}
#[test]
fn index_does_not_exist() {
let actual = nu!(
cwd: ".", pipeline(
r#"[1,2,3] | upsert 4 4"#
));
let actual = nu!("[1,2,3] | upsert 4 4");
assert!(actual.err.contains("index too large (max: 3)"));
}
#[test]
fn upsert_empty() {
let actual = nu!(
cwd: ".", pipeline(
r#"[] | upsert 1 1"#
));
let actual = nu!("[] | upsert 1 1");
assert!(actual.err.contains("index too large (max: 0)"));
}