From 160339bd1fd9ae3d115b4bebe84735844c92eef1 Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Mon, 10 Jan 2022 13:29:52 -0800 Subject: [PATCH] add in a new select test that exercises a different match arm of the select command (#718) --- crates/nu-command/src/filters/select.rs | 62 ------------------------- src/tests/test_table_operations.rs | 10 +++- 2 files changed, 9 insertions(+), 63 deletions(-) diff --git a/crates/nu-command/src/filters/select.rs b/crates/nu-command/src/filters/select.rs index f1fa4e7780..da71e48ff3 100644 --- a/crates/nu-command/src/filters/select.rs +++ b/crates/nu-command/src/filters/select.rs @@ -133,65 +133,3 @@ fn select( _ => Ok(PipelineData::new(span)), } } - -// #[cfg(test)] -// mod tests { -// use nu_protocol::ColumnPath; -// use nu_source::Span; -// use nu_source::SpannedItem; -// use nu_source::Tag; -// use nu_stream::InputStream; -// use nu_test_support::value::nothing; -// use nu_test_support::value::row; -// use nu_test_support::value::string; - -// use super::select; -// use super::Command; -// use super::ShellError; - -// #[test] -// fn examples_work_as_expected() -> Result<(), ShellError> { -// use crate::examples::test as test_examples; - -// test_examples(Command {}) -// } - -// #[test] -// fn select_using_sparse_table() { -// // Create a sparse table with 3 rows: -// // col_foo | col_bar -// // ----------------- -// // foo | -// // | bar -// // foo | -// let input = vec![ -// row(indexmap! {"col_foo".into() => string("foo")}), -// row(indexmap! {"col_bar".into() => string("bar")}), -// row(indexmap! {"col_foo".into() => string("foo")}), -// ]; - -// let expected = vec![ -// row( -// indexmap! {"col_none".into() => nothing(), "col_foo".into() => string("foo"), "col_bar".into() => nothing()}, -// ), -// row( -// indexmap! {"col_none".into() => nothing(), "col_foo".into() => nothing(), "col_bar".into() => string("bar")}, -// ), -// row( -// indexmap! {"col_none".into() => nothing(), "col_foo".into() => string("foo"), "col_bar".into() => nothing()}, -// ), -// ]; - -// let actual = select( -// Tag::unknown(), -// vec![ -// ColumnPath::build(&"col_none".to_string().spanned(Span::test_data())), -// ColumnPath::build(&"col_foo".to_string().spanned(Span::test_data())), -// ColumnPath::build(&"col_bar".to_string().spanned(Span::test_data())), -// ], -// input.into(), -// ); - -// assert_eq!(Ok(expected), actual.map(InputStream::into_vec)); -// } -// } diff --git a/src/tests/test_table_operations.rs b/src/tests/test_table_operations.rs index 245d8accb2..7ae4494d01 100644 --- a/src/tests/test_table_operations.rs +++ b/src/tests/test_table_operations.rs @@ -186,13 +186,21 @@ fn get() -> TestResult { } #[test] -fn select() -> TestResult { +fn select_1() -> TestResult { run_test( r#"([[name, age]; [a, 1], [b, 2]]) | select name | get 1 | get name"#, "b", ) } +#[test] +fn select_2() -> TestResult { + run_test( + r#"[[name, age]; [a, 1] [b, 2]] | get 1 | select age | get age"#, + "2", + ) +} + #[test] fn update_will_insert() -> TestResult { run_test(r#"{} | update a b | get a"#, "b")