From b674cee9d2ebba828a2c1b125c77df092260aabc Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 4 Nov 2020 09:26:07 +1300 Subject: [PATCH] Remove the recursely-dep'd tests (#2727) --- Cargo.lock | 1 - crates/nu-value-ext/Cargo.toml | 3 - crates/nu-value-ext/src/lib.rs | 3 - crates/nu-value-ext/src/tests.rs | 139 ------------------------------- 4 files changed, 146 deletions(-) delete mode 100644 crates/nu-value-ext/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index ea13d1ccaa..f20a532ec1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3145,7 +3145,6 @@ dependencies = [ "nu-errors", "nu-protocol", "nu-source", - "nu-test-support", "num-traits 0.2.12", ] diff --git a/crates/nu-value-ext/Cargo.toml b/crates/nu-value-ext/Cargo.toml index 94152b337e..76f90eb4e0 100644 --- a/crates/nu-value-ext/Cargo.toml +++ b/crates/nu-value-ext/Cargo.toml @@ -17,6 +17,3 @@ nu-source = {path = "../nu-source", version = "0.22.0"} indexmap = {version = "1.6.0", features = ["serde-1"]} itertools = "0.9.0" num-traits = "0.2.12" - -[dev-dependencies] -nu-test-support = {path = "../nu-test-support", version = "0.22.0"} diff --git a/crates/nu-value-ext/src/lib.rs b/crates/nu-value-ext/src/lib.rs index 4bf8feaac3..7cec7aea31 100644 --- a/crates/nu-value-ext/src/lib.rs +++ b/crates/nu-value-ext/src/lib.rs @@ -1,6 +1,3 @@ -#[cfg(test)] -mod tests; - use indexmap::indexmap; use indexmap::set::IndexSet; use itertools::Itertools; diff --git a/crates/nu-value-ext/src/tests.rs b/crates/nu-value-ext/src/tests.rs deleted file mode 100644 index db40e313e3..0000000000 --- a/crates/nu-value-ext/src/tests.rs +++ /dev/null @@ -1,139 +0,0 @@ -use super::*; -use nu_test_support::value::*; - -use indexmap::indexmap; - -#[test] -fn forgiving_insertion_test_1() { - let field_path = column_path("crate.version").as_column_path().unwrap(); - - let version = string("nuno"); - - let value = UntaggedValue::row(indexmap! { - "package".into() => - row(indexmap! { - "name".into() => string("nu"), - "version".into() => string("0.20.0") - }) - }); - - assert_eq!( - *value - .into_untagged_value() - .forgiving_insert_data_at_column_path(&field_path.item, version) - .unwrap() - .get_data_by_column_path(&field_path, Box::new(error_callback("crate.version"))) - .unwrap(), - *string("nuno") - ); -} - -#[test] -fn forgiving_insertion_test_2() { - let field_path = column_path("things.0").as_column_path().unwrap(); - - let version = string("arepas"); - - let value = UntaggedValue::row(indexmap! { - "pivot_mode".into() => string("never"), - "things".into() => table(&[string("frijoles de Andrés"), int(1)]), - "color_config".into() => - row(indexmap! { - "header_align".into() => string("left"), - "index_color".into() => string("cyan_bold") - }) - }); - - assert_eq!( - *value - .into_untagged_value() - .forgiving_insert_data_at_column_path(&field_path.item, version) - .unwrap() - .get_data_by_column_path(&field_path, Box::new(error_callback("things.0"))) - .unwrap(), - *string("arepas") - ); -} - -#[test] -fn forgiving_insertion_test_3() { - let field_path = column_path("color_config.arepa_color") - .as_column_path() - .unwrap(); - let pizza_path = column_path("things.0").as_column_path().unwrap(); - - let entry = string("amarillo"); - - let value = UntaggedValue::row(indexmap! { - "pivot_mode".into() => string("never"), - "things".into() => table(&[string("Arepas de Yehuda"), int(1)]), - "color_config".into() => - row(indexmap! { - "header_align".into() => string("left"), - "index_color".into() => string("cyan_bold") - }) - }); - - assert_eq!( - *value - .clone() - .into_untagged_value() - .forgiving_insert_data_at_column_path(&field_path, entry.clone()) - .unwrap() - .get_data_by_column_path( - &field_path.item, - Box::new(error_callback("color_config.arepa_color")) - ) - .unwrap(), - *string("amarillo") - ); - - assert_eq!( - *value - .into_untagged_value() - .forgiving_insert_data_at_column_path(&field_path.item, entry) - .unwrap() - .get_data_by_column_path(&pizza_path, Box::new(error_callback("things.0"))) - .unwrap(), - *string("Arepas de Yehuda") - ); -} - -#[test] -fn get_row_data_by_key() { - let row = row(indexmap! { - "lines".to_string() => int(0), - "words".to_string() => int(7), - }); - assert_eq!( - row.get_data_by_key("lines".spanned_unknown()).unwrap(), - int(0) - ); - assert!(row.get_data_by_key("chars".spanned_unknown()).is_none()); -} - -#[test] -fn get_table_data_by_key() { - let row1 = row(indexmap! { - "lines".to_string() => int(0), - "files".to_string() => int(10), - }); - - let row2 = row(indexmap! { - "files".to_string() => int(1) - }); - - let table_value = table(&[row1, row2]); - assert_eq!( - table_value - .get_data_by_key("files".spanned_unknown()) - .unwrap(), - table(&[int(10), int(1)]) - ); - assert_eq!( - table_value - .get_data_by_key("chars".spanned_unknown()) - .unwrap(), - table(&[nothing(), nothing()]) - ); -}