Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
Add simple test for include
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Feb 2, 2022
1 parent 0ce08b2 commit 9259283
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 0 deletions.
30 changes: 30 additions & 0 deletions data/review/include/animals_complex.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
11 changes: 11 additions & 0 deletions data/review/include/append.fix
Original file line number Diff line number Diff line change
@@ -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")
10 changes: 10 additions & 0 deletions data/review/include/append.flux
Original file line number Diff line number Diff line change
@@ -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")
;
24 changes: 24 additions & 0 deletions data/review/include/expected.json
Original file line number Diff line number Diff line change
@@ -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"
}
11 changes: 11 additions & 0 deletions data/review/include/prepend.fix
Original file line number Diff line number Diff line change
@@ -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 ")
24 changes: 24 additions & 0 deletions data/review/include/result.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 9259283

Please sign in to comment.