mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 00:43:33 +01:00
ae5f3c8210
* headers plugin
* Remove plugin
* Add non-functioning headers command
* Add ability to extract headers from first row
* Refactor header extraction
* Rebuild indexmap with proper headers
* Rebuild result properly
* Compiling, probably wrapped too much?
* Refactoring
* Deal with case of empty header cell
* Deal with case of empty header cell
* Fix formatting
* Fix linting, attempt 2.
* Move whole_stream_command(Headers) to more appropriate section
* ... more linting
* Return Err(ShellError...) instead of panic, yield each row instead of entire table
* Insert Column[index] if no header info is found.
* Update error description
* Add initial test
* Add tests for headers command
* Lint test cases in headers
* Change ShellError for headers, Add sample_headers file to utils.rs
* Add empty sheet to test file
* Revert "Add empty sheet to test file"
This reverts commit a4bf38a31d
.
* Show error message when given empty table
32 lines
657 B
Rust
32 lines
657 B
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
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#"
|
|
open sample_headers.xlsx
|
|
| get Sheet1
|
|
| headers
|
|
| get Column1
|
|
| from-json"#
|
|
));
|
|
|
|
assert_eq!(actual, "r1c1r2c1")
|
|
}
|