From 9259283795eb69b904fcb490ed179533df05026b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Wed, 2 Feb 2022 09:25:34 +0100 Subject: [PATCH] Add simple test for include https://github.com/metafacture/metafacture-fix/issues/12 --- data/review/include/animals_complex.json | 30 ++++++++++++++++++++++++ data/review/include/append.fix | 11 +++++++++ data/review/include/append.flux | 10 ++++++++ data/review/include/expected.json | 24 +++++++++++++++++++ data/review/include/prepend.fix | 11 +++++++++ data/review/include/result.json | 24 +++++++++++++++++++ 6 files changed, 110 insertions(+) create mode 100644 data/review/include/animals_complex.json create mode 100644 data/review/include/append.fix create mode 100644 data/review/include/append.flux create mode 100644 data/review/include/expected.json create mode 100644 data/review/include/prepend.fix create mode 100644 data/review/include/result.json diff --git a/data/review/include/animals_complex.json b/data/review/include/animals_complex.json new file mode 100644 index 0000000..c8e030b --- /dev/null +++ b/data/review/include/animals_complex.json @@ -0,0 +1,30 @@ +{ + "animals": ["dog", "cat", "zebra"], + "bnimals": ["dog", "cat", "zebra"], + "animal": "bunny", + "animols": { + "name": "bird", + "type": "TEST" + }, + "ANIMALS": ["dog", "cat", "zebra"], + "others": [ + { + "name": "Jake", + "animal": "dog" + }, + { + "name": "Finn", + "animal": "human" + } + ], + "OTHERS": [ + { + "name": "Jake", + "animal": "dog" + }, + { + "name": "Finn", + "animal": "human" + } + ] +} \ No newline at end of file diff --git a/data/review/include/append.fix b/data/review/include/append.fix new file mode 100644 index 0000000..c686b50 --- /dev/null +++ b/data/review/include/append.fix @@ -0,0 +1,11 @@ +append("animal", " is cool") +append("animols.name", " boss") + +append("animals[].1", " is cool") + +append("bnimals[].*", " is cool") + +append("others[].1.animal", " is cool") +append("OTHERS[].*.animal", " is cool") + +include("data/review/include/prepend.fix") \ No newline at end of file diff --git a/data/review/include/append.flux b/data/review/include/append.flux new file mode 100644 index 0000000..e372598 --- /dev/null +++ b/data/review/include/append.flux @@ -0,0 +1,10 @@ +infile = FLUX_DIR + "animals_complex.json"; + +infile +| open-file +| as-records +| decode-json +| fix(FLUX_DIR + "append.fix") +| encode-json(prettyPrinting="true") +| write(FLUX_DIR + "result.json") +; diff --git a/data/review/include/expected.json b/data/review/include/expected.json new file mode 100644 index 0000000..847e75c --- /dev/null +++ b/data/review/include/expected.json @@ -0,0 +1,24 @@ +{ + "animals" : [ "Yeah dog is cool", "cat", "zebra" ], + "bnimals" : [ "Muh dog is cool", "Muh cat is cool", "Muh zebra is cool" ], + "animols" : { + "type" : "TEST", + "name" : "Mr bird boss" + }, + "ANIMALS" : [ "dog", "cat", "zebra" ], + "others" : [ { + "animal" : "dog is cool", + "name" : "Hello Jake" + }, { + "name" : "Finn", + "animal" : "human" + } ], + "OTHERS" : [ { + "animal" : "dog is cool", + "name" : "Hi Jake" + }, { + "animal" : "human is cool", + "name" : "Hi Finn" + } ], + "animal" : "What a nice bunny is cool" +} \ No newline at end of file diff --git a/data/review/include/prepend.fix b/data/review/include/prepend.fix new file mode 100644 index 0000000..db9326a --- /dev/null +++ b/data/review/include/prepend.fix @@ -0,0 +1,11 @@ +prepend("animal", "What a nice ") +prepend("animols.name", "Mr ") + + +prepend("animals[].1", "Yeah ") + +prepend("bnimals[].*", "Muh ") + +prepend("others[].1.name", "Hello ") + +prepend("OTHERS[].*.name", "Hi ") \ No newline at end of file diff --git a/data/review/include/result.json b/data/review/include/result.json new file mode 100644 index 0000000..29e9ee0 --- /dev/null +++ b/data/review/include/result.json @@ -0,0 +1,24 @@ +{ + "animals" : [ "Yeah dog is cool", "cat", "zebra" ], + "bnimals" : [ "Muh dog is cool", "Muh cat is cool", "Muh zebra is cool" ], + "animols" : { + "type" : "TEST", + "name" : "Mr bird boss" + }, + "ANIMALS" : [ "dog", "cat", "zebra" ], + "others" : [ { + "animal" : "dog is cool", + "name" : "Hello Jake" + }, { + "name" : "Finn", + "animal" : "human" + } ], + "OTHERS" : [ { + "animal" : "dog is cool", + "name" : "Hi Jake" + }, { + "animal" : "human is cool", + "name" : "Hi Finn" + } ], + "animal" : "What a nice bunny is cool" +}