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

@ -77,7 +77,21 @@ On Windows, an extra 'prefix' column is added."#
Example {
description: "Parse a single path",
example: r"'C:\Users\viking\spam.txt' | path parse",
result: None,
result: Some(Value::Record {
cols: vec![
"prefix".into(),
"parent".into(),
"stem".into(),
"extension".into(),
],
vals: vec![
Value::test_string("C:"),
Value::test_string(r"C:\Users\viking"),
Value::test_string("spam"),
Value::test_string("txt"),
],
span: Span::test_data(),
}),
},
Example {
description: "Replace a complex extension",
@ -87,7 +101,21 @@ On Windows, an extra 'prefix' column is added."#
Example {
description: "Ignore the extension",
example: r"'C:\Users\viking.d' | path parse -e ''",
result: None,
result: Some(Value::Record {
cols: vec![
"prefix".into(),
"parent".into(),
"stem".into(),
"extension".into(),
],
vals: vec![
Value::test_string("C:"),
Value::test_string(r"C:\Users"),
Value::test_string("viking.d"),
Value::test_string(""),
],
span: Span::test_data(),
}),
},
Example {
description: "Parse all paths under the 'name' column",
@ -103,7 +131,15 @@ On Windows, an extra 'prefix' column is added."#
Example {
description: "Parse a path",
example: r"'/home/viking/spam.txt' | path parse",
result: None,
result: Some(Value::Record {
cols: vec!["parent".into(), "stem".into(), "extension".into()],
vals: vec![
Value::test_string("/home/viking"),
Value::test_string("spam"),
Value::test_string("txt"),
],
span: Span::test_data(),
}),
},
Example {
description: "Replace a complex extension",
@ -113,7 +149,15 @@ On Windows, an extra 'prefix' column is added."#
Example {
description: "Ignore the extension",
example: r"'/etc/conf.d' | path parse -e ''",
result: None,
result: Some(Value::Record {
cols: vec!["parent".into(), "stem".into(), "extension".into()],
vals: vec![
Value::test_string("/etc"),
Value::test_string("conf.d"),
Value::test_string(""),
],
span: Span::test_data(),
}),
},
Example {
description: "Parse all paths under the 'name' column",