Improve test coverage of command examples (#5650)

* Ignore `cargo tarpaulin` output files

* Add expected result for `columns` example

Examples without provided expected output will never be tested.
The subset of commands available in `test_examples()` is limited thus
excluding the tests depending on other commands

* Add example test harness to `reject`

* Test and fix `wrap` example

* Test and fix `drop column` example

* Update `from ods` examples

* Update `from xlsx` examples

* Run `to nuon` examples

* Run `hash base64` examples

* Add example output to `path parse`

* Test and fix the `grid` examples
This commit is contained in:
Stefan Holderbach
2022-05-26 20:51:31 +02:00
committed by GitHub
parent 230c36f2fb
commit 507f24d029
11 changed files with 156 additions and 26 deletions

View File

@ -55,12 +55,12 @@ impl Command for FromOds {
vec![
Example {
description: "Convert binary .ods data to a table",
example: "open test.txt | from ods",
example: "open --raw test.ods | from ods",
result: None,
},
Example {
description: "Convert binary .ods data to a table, specifying the tables",
example: "open test.txt | from ods -s [Spreadsheet1]",
example: "open --raw test.ods | from ods -s [Spreadsheet1]",
result: None,
},
]

View File

@ -55,12 +55,12 @@ impl Command for FromXlsx {
vec![
Example {
description: "Convert binary .xlsx data to a table",
example: "open test.txt | from xlsx",
example: "open --raw test.xlsx | from xlsx",
result: None,
},
Example {
description: "Convert binary .xlsx data to a table, specifying the tables",
example: "open test.txt | from xlsx -s [Spreadsheet1]",
example: "open --raw test.xlsx | from xlsx -s [Spreadsheet1]",
result: None,
},
]

View File

@ -39,7 +39,7 @@ impl Command for ToNuon {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Outputs a nuon string representing the contents of this table",
description: "Outputs a nuon string representing the contents of this list",
example: "[1 2 3] | to nuon",
result: Some(Value::test_string("[1, 2, 3]")),
}]
@ -147,3 +147,13 @@ fn to_nuon(call: &Call, input: PipelineData) -> Result<String, ShellError> {
value_to_string(&v, call.head)
}
#[cfg(test)]
mod test {
#[test]
fn test_examples() {
use super::ToNuon;
use crate::test_examples;
test_examples(ToNuon {})
}
}