fixed some more tests (#4607)

This commit is contained in:
Darren Schroeder 2022-02-22 10:32:29 -06:00 committed by GitHub
parent 25712760ba
commit f507613b38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 18 additions and 60 deletions

View File

@ -2,8 +2,6 @@ use nu_test_support::nu;
use nu_test_support::playground::Playground;
use std::fs;
// FIXME: jt: needs more work
#[ignore]
#[test]
fn def_with_comment() {
Playground::setup("def_with_comment", |dirs, _| {
@ -14,7 +12,7 @@ def e [arg] {echo $arg}
fs::write(dirs.root().join("def_test"), data).expect("Unable to write file");
let actual = nu!(
cwd: dirs.root(),
"source def_test; help e | to json"
"source def_test; help e | to json -r"
);
assert!(actual.out.contains("My echo\\n\\n"));

View File

@ -2,8 +2,6 @@ use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
// FIXME: jt: needs more work
#[ignore]
#[test]
fn flatten_nested_tables_with_columns() {
let actual = nu!(
@ -11,7 +9,7 @@ fn flatten_nested_tables_with_columns() {
r#"
echo [[origin, people]; [Ecuador, ('Andres' | wrap name)]]
[[origin, people]; [Nu, ('nuno' | wrap name)]]
| flatten
| flatten | flatten
| get name
| str collect ','
"#
@ -20,16 +18,14 @@ fn flatten_nested_tables_with_columns() {
assert_eq!(actual.out, "Andres,nuno");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn flatten_nested_tables_that_have_many_columns() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [[origin, people]; [Ecuador, (echo [[name, meal]; ['Andres', 'arepa']])]]
[[origin, people]; [USA, (echo [[name, meal]; ['Katz', 'nurepa']])]]
| flatten
[[origin, people]; [USA, (echo [[name, meal]; ['Katz', 'nurepa']])]]
| flatten | flatten
| get meal
| str collect ','
"#

View File

@ -107,8 +107,6 @@ fn moves_a_column_after() {
})
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn moves_columns_after() {
Playground::setup("move_column_test_4", |dirs, sandbox| {
@ -132,7 +130,7 @@ fn moves_columns_after() {
r#"
open sample.csv
| move letters and_more --after column1
| get
| columns
| select 1 2
| str collect
"#

View File

@ -2,8 +2,6 @@ use nu_test_support::fs::Stub::EmptyFile;
use nu_test_support::nu;
use nu_test_support::playground::Playground;
// FIXME: jt: needs more work
#[ignore]
#[test]
fn checks_if_existing_file_exists() {
Playground::setup("path_exists_1", |dirs, sandbox| {

View File

@ -15,8 +15,6 @@ fn returns_type_of_missing_file() {
assert_eq!(actual.out, "");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn returns_type_of_existing_file() {
Playground::setup("path_expand_1", |dirs, sandbox| {
@ -36,8 +34,6 @@ fn returns_type_of_existing_file() {
})
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn returns_type_of_existing_directory() {
Playground::setup("path_expand_1", |dirs, sandbox| {

View File

@ -54,7 +54,7 @@ fn reduce_numbered_example() {
cwd: ".", pipeline(
r#"
echo one longest three bar
reduce -n { |it, acc| if ($it | str length) > ($acc | str length) {echo $it} else {echo $acc}}
| reduce -n { |it, acc| if ($it.item | str length) > ($acc | str length) {echo $it.item} else {echo $acc}}
| get index
"#
)

View File

@ -106,8 +106,6 @@ fn column_names_with_spaces() {
assert_eq!(actual.out, "Robalino Jnth");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn ignores_duplicate_columns_selected() {
let actual = nu!(cwd: ".", pipeline(
@ -119,7 +117,7 @@ fn ignores_duplicate_columns_selected() {
[Andrés Jnth]
]
| select "first name" "last name" "first name"
| get
| columns
| str collect " "
"#
));

View File

@ -21,8 +21,6 @@ fn by_column() {
assert_eq!(actual.out, "description");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn by_invalid_column() {
let actual = nu!(
@ -41,8 +39,8 @@ fn by_invalid_column() {
"#
));
assert!(actual.err.contains("Can not find column to sort by"));
assert!(actual.err.contains("invalid column"));
assert!(actual.err.contains("Cannot find column"));
assert!(actual.err.contains("value originates here"));
}
// FIXME: jt: needs more work
@ -53,15 +51,14 @@ fn by_invalid_types() {
cwd: "tests/fixtures/formats", pipeline(
r#"
open cargo_sample.toml --raw
| echo [1 "foo"]
| echo ["foo" 1]
| sort-by
| json -r
"#
));
assert!(actual.err.contains("Not all values can be compared"));
assert!(actual
.err
.contains("Unable to sort values, as \"integer\" cannot compare against \"string\""));
let json_output = r#"[1,"foo"]"#;
assert_eq!(actual.out, json_output);
}
#[test]
@ -93,7 +90,6 @@ fn ls_sort_by_name_sensitive() {
"#
));
//let json_output = r#"[{"name":"B.txt"},{"name":"C"},{"name":"a.txt"}]"#;
let json_output = r#"[{"name": "B.txt"},{"name": "C"},{"name": "a.txt"}]"#;
assert_eq!(actual.out, json_output);

View File

@ -101,8 +101,6 @@ fn try_source_foo_without_quotes_in(testdir: &str, playdir: &str) {
});
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn sources_unicode_file_in_normal_dir() {
try_source_foo_with_single_quotes_in("foo", "source_test_1");
@ -110,8 +108,6 @@ fn sources_unicode_file_in_normal_dir() {
try_source_foo_without_quotes_in("foo", "source_test_3");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn sources_unicode_file_in_unicode_dir_without_spaces_1() {
try_source_foo_with_single_quotes_in("🚒", "source_test_4");
@ -119,8 +115,6 @@ fn sources_unicode_file_in_unicode_dir_without_spaces_1() {
try_source_foo_without_quotes_in("🚒", "source_test_6");
}
// FIXME: jt: needs more work
#[ignore]
#[cfg(not(windows))] // ':' is not allowed in Windows paths
#[test]
fn sources_unicode_file_in_unicode_dir_without_spaces_2() {

View File

@ -65,8 +65,6 @@ fn test_redirection2() {
assert_eq!(actual.out, "10");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn with_env_hides_variables_in_parent_scope() {
let actual = nu!(
@ -82,8 +80,6 @@ fn with_env_hides_variables_in_parent_scope() {
);
assert_eq!(actual.out, "11");
assert!(actual.err.contains("error"));
assert!(actual.err.contains("Unknown column"));
}
// FIXME: jt: needs more work

View File

@ -5,25 +5,13 @@ use nu_test_support::{nu, pipeline};
const ZIP_POWERED_TEST_ASSERTION_SCRIPT: &str = r#"
def expect [
left,
right,
--to-eq
--to-eq,
right
] {
$left | zip { $right } | all? {
$it.name.0 == $it.name.1 && $it.commits.0 == $it.commits.1
$left | zip { $right } | all? {|row|
$row.name.0 == $row.name.1 && $row.commits.0 == $row.commits.1
}
}
def add-commits [n] {
each {
let contributor = $it;
let name = $it.name;
let commits = $it.commits;
$contributor | merge {
[[commits]; [($commits + $n)]]
}
}
}
"#;
// FIXME: jt: needs more work
@ -48,7 +36,7 @@ fn zips_two_tables() {
[ jt, 20]
]);
let actual = ($contributors | add-commits 10);
let actual = ($contributors | update commits {{ |i| ($i.commits + 10) }});
expect $actual --to-eq [[name, commits]; [andres, 20] [jt, 30]]
"#,