mirror of
https://github.com/nushell/nushell.git
synced 2025-07-09 02:48:17 +02:00
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:
committed by
GitHub
parent
230c36f2fb
commit
507f24d029
@ -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,
|
||||
},
|
||||
]
|
||||
|
@ -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,
|
||||
},
|
||||
]
|
||||
|
@ -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 {})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user