Skip to content

Commit

Permalink
add test for mergable objects within arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
grische committed Jul 24, 2024
1 parent 2a1a27b commit d4a1d39
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions json-to-go.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function testFiles() {
const testCases = [
"duplicate-top-level-structs",
"double-nested-objects",
"array-with-mergable-objects",
];

for (const testCase of testCases) {
Expand Down
15 changes: 15 additions & 0 deletions tests/array-with-mergable-objects.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type AutoGenerated struct {
Booleanfield bool `json:"booleanfield"`
Inconsistentarray []Inconsistentarray `json:"inconsistentarray,omitempty"`
Date string `json:"date,omitempty"`
}
type Features struct {
Age int `json:"age,omitempty"`
Height int `json:"height,omitempty"`
Gender string `json:"gender,omitempty"`
}
type Inconsistentarray struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Features Features `json:"features,omitempty"`
}
28 changes: 28 additions & 0 deletions tests/array-with-mergable-objects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"booleanfield": true,
"inconsistentarray": [
{
"id": 1,
"name": "John Doe",
"features": {
"age": 49,
"height": 175
}
},
{
"id": 2,
"name": "Jane Doe",
"features": {
"height": 164
}
},
{
"id": 3,
"name": "John Doe",
"features": {
"gender": "unknown"
}
}
],
"date": "2024-07-22"
}

0 comments on commit d4a1d39

Please sign in to comment.