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

@ -14,7 +14,6 @@ fn filters_by_unit_size_comparison() {
#[test]
fn filters_with_nothing_comparison() {
let actual = nu!(
cwd: "tests/fixtures/formats",
r#"'[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum"#
);
@ -33,20 +32,14 @@ fn where_inside_block_works() {
#[test]
fn filters_with_0_arity_block() {
let actual = nu!(
cwd: ".",
"[1 2 3 4] | where {|| $in < 3 } | to nuon"
);
let actual = nu!("[1 2 3 4] | where {|| $in < 3 } | to nuon");
assert_eq!(actual.out, "[1, 2]");
}
#[test]
fn filters_with_1_arity_block() {
let actual = nu!(
cwd: ".",
"[1 2 3 6 7 8] | where {|e| $e < 5 } | to nuon"
);
let actual = nu!("[1 2 3 6 7 8] | where {|e| $e < 5 } | to nuon");
assert_eq!(actual.out, "[1, 2, 3]");
}
@ -64,7 +57,6 @@ fn unique_env_each_iteration() {
#[test]
fn where_in_table() {
let actual = nu!(
cwd: "tests/fixtures/formats",
r#"'[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in ["foo"] | get size | math sum"#
);
@ -74,7 +66,6 @@ fn where_in_table() {
#[test]
fn where_not_in_table() {
let actual = nu!(
cwd: "tests/fixtures/formats",
r#"'[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in ["foo"] | get size | math sum"#
);
@ -83,10 +74,7 @@ fn where_not_in_table() {
#[test]
fn where_uses_enumerate_index() {
let actual = nu!(
cwd: ".",
r#"[7 8 9 10] | enumerate | where {|el| $el.index < 2 } | to nuon"#
);
let actual = nu!("[7 8 9 10] | enumerate | where {|el| $el.index < 2 } | to nuon");
assert_eq!(actual.out, "[[index, item]; [0, 7], [1, 8]]");
}