Add tests for headers command

This commit is contained in:
Sam Hedin 2020-03-28 19:45:34 +01:00
parent a520f8e370
commit 4cb22a6a45
2 changed files with 18 additions and 1 deletions

View File

@ -1,7 +1,22 @@
use nu_test_support::{nu, pipeline};
#[test]
fn headers() {
fn headers_uses_first_row_as_header() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample_headers.xlsx
| get Sheet1
| headers
| get header0
| from-json"#
));
assert_eq!(actual, "r1c0r2c0")
}
#[test]
fn headers_adds_missing_column_name() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
@ -11,5 +26,6 @@ fn headers() {
| get Column1
| from-json"#
));
assert_eq!(actual, "r1c1r2c1")
}

View File

@ -10,6 +10,7 @@ mod first;
mod format;
mod get;
mod group_by;
mod headers;
mod histogram;
mod insert;
mod last;