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

Commit

Permalink
Add test for appending objects to array
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Feb 1, 2022
1 parent e271ce1 commit a45d39c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions data/testing/appendArray_objects/animalsObjects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"animals":[
{"animal": "dog"},
{"animal": "cat"}
],
"others": {"animal": "human"},
"fictional": {"animal": "unicorn"}
}
10 changes: 10 additions & 0 deletions data/testing/appendArray_objects/expected_object.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"animals":[
{"animal": "dog"},
{"animal": "cat"},
{"animal": "human"},
{"animal": "unicorn"},
{"animal": "earthworm"}
],
"others": {"animal": "human"}
}
12 changes: 12 additions & 0 deletions data/testing/appendArray_objects/result_object.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"animals" : [ {
"animal" : "dog"
}, {
"animal" : "cat"
}, {
"animal" : "earthworm"
} ],
"others" : {
"animal" : "human"
}
}
5 changes: 5 additions & 0 deletions data/testing/appendArray_objects/test_append_object.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
copy_field("others", "animals[].$append")

move_field("fictional", "animals[].$append")

add_field("animals[].$append.animal", "earthworm")
10 changes: 10 additions & 0 deletions data/testing/appendArray_objects/test_append_object.flux
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
infile = FLUX_DIR + "animalsObjects.json";

infile
| open-file
| as-records
| decode-json
| fix(FLUX_DIR + "test_append_object.fix")
| encode-json(prettyPrinting="true")
| write(FLUX_DIR + "result_object.json")
;

0 comments on commit a45d39c

Please sign in to comment.