From f3d14aad48a50608b3208c7b86a81457e57caadb Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 3 Jun 2019 12:37:16 +1200 Subject: [PATCH] Add more tests --- src/commands/classified.rs | 2 +- src/tests.rs | 25 +++++++++++++++++++++++++ tests/json_roundtrip.out | 1 + tests/json_roundtrip.txt | 2 ++ tests/open_json.out | 1 + tests/open_json.txt | 2 ++ tests/sort_by.out | 1 + tests/sort_by.txt | 2 ++ tests/split.out | 2 ++ tests/split.txt | 2 ++ tests/test.json | 22 ++++++++++++++++++++++ tests/toml_roundtrip.out | 1 + tests/toml_roundtrip.txt | 2 ++ 13 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/json_roundtrip.out create mode 100644 tests/json_roundtrip.txt create mode 100644 tests/open_json.out create mode 100644 tests/open_json.txt create mode 100644 tests/sort_by.out create mode 100644 tests/sort_by.txt create mode 100644 tests/split.out create mode 100644 tests/split.txt create mode 100644 tests/test.json create mode 100644 tests/toml_roundtrip.out create mode 100644 tests/toml_roundtrip.txt diff --git a/src/commands/classified.rs b/src/commands/classified.rs index 10be56d4c..b1f4f734f 100644 --- a/src/commands/classified.rs +++ b/src/commands/classified.rs @@ -167,7 +167,7 @@ impl ExternalCommand { let mut first = true; for i in &inputs { if !first { - new_arg_string.push_str(" && "); + new_arg_string.push_str("&&"); new_arg_string.push_str(&self.name); } else { first = false; diff --git a/src/tests.rs b/src/tests.rs index 9910950d5..13142dde7 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -58,4 +58,29 @@ mod tests { fn test_toml() { test_helper("open_toml"); } + + #[test] + fn test_json() { + test_helper("open_json"); + } + + #[test] + fn json_roundtrip() { + test_helper("json_roundtrip"); + } + + #[test] + fn toml_roundtrip() { + test_helper("toml_roundtrip"); + } + + #[test] + fn sort_by() { + test_helper("sort_by"); + } + + #[test] + fn split() { + test_helper("split"); + } } \ No newline at end of file diff --git a/tests/json_roundtrip.out b/tests/json_roundtrip.out new file mode 100644 index 000000000..ba2d8d98d --- /dev/null +++ b/tests/json_roundtrip.out @@ -0,0 +1 @@ +"example glossary" diff --git a/tests/json_roundtrip.txt b/tests/json_roundtrip.txt new file mode 100644 index 000000000..285697ec0 --- /dev/null +++ b/tests/json_roundtrip.txt @@ -0,0 +1,2 @@ +open tests\test.json | to-json | from-json | select glossary.title | echo $it +exit diff --git a/tests/open_json.out b/tests/open_json.out new file mode 100644 index 000000000..10a6a46d7 --- /dev/null +++ b/tests/open_json.out @@ -0,0 +1 @@ +markup diff --git a/tests/open_json.txt b/tests/open_json.txt new file mode 100644 index 000000000..9126fb3f6 --- /dev/null +++ b/tests/open_json.txt @@ -0,0 +1,2 @@ +open tests\test.json | select glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it +exit diff --git a/tests/sort_by.out b/tests/sort_by.out new file mode 100644 index 000000000..e1b39b006 --- /dev/null +++ b/tests/sort_by.out @@ -0,0 +1 @@ +description diff --git a/tests/sort_by.txt b/tests/sort_by.txt new file mode 100644 index 000000000..235c76b8e --- /dev/null +++ b/tests/sort_by.txt @@ -0,0 +1,2 @@ +open tests\test.toml --raw | split-row "\n" | skip 1 | first 4 | split-column "=" | sort-by Column1 | skip 1 | first 1 | select Column1 | trim | echo $it +exit diff --git a/tests/split.out b/tests/split.out new file mode 100644 index 000000000..4c45f1172 --- /dev/null +++ b/tests/split.out @@ -0,0 +1,2 @@ +name +version diff --git a/tests/split.txt b/tests/split.txt new file mode 100644 index 000000000..8b8189f4a --- /dev/null +++ b/tests/split.txt @@ -0,0 +1,2 @@ +open tests\test.toml --raw | split-row "\n" | skip 1 | first 2 | split-column "=" | select Column1 | trim | echo $it +exit diff --git a/tests/test.json b/tests/test.json new file mode 100644 index 000000000..d5ca56d19 --- /dev/null +++ b/tests/test.json @@ -0,0 +1,22 @@ +{ + "glossary": { + "title": "example glossary", + "GlossDiv": { + "title": "S", + "GlossList": { + "GlossEntry": { + "ID": "SGML", + "SortAs": "SGML", + "GlossTerm": "Standard Generalized Markup Language", + "Acronym": "SGML", + "Abbrev": "ISO 8879:1986", + "GlossDef": { + "para": "A meta-markup language, used to create markup languages such as DocBook.", + "GlossSeeAlso": ["GML", "XML"] + }, + "GlossSee": "markup" + } + } + } + } +} \ No newline at end of file diff --git a/tests/toml_roundtrip.out b/tests/toml_roundtrip.out new file mode 100644 index 000000000..f5f171aac --- /dev/null +++ b/tests/toml_roundtrip.out @@ -0,0 +1 @@ +nu diff --git a/tests/toml_roundtrip.txt b/tests/toml_roundtrip.txt new file mode 100644 index 000000000..1d150b943 --- /dev/null +++ b/tests/toml_roundtrip.txt @@ -0,0 +1,2 @@ +open tests\test.toml | to-toml | from-toml | select package.name | echo $it +exit