Skip to content

Commit

Permalink
add tests for IndexAll() followed by Child()
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarguimaraes committed Mar 19, 2024
1 parent 4653a1b commit 19b7508
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ store:
price: 10
- author: ken
price: 12
title: dictionary
bicycle:
color: red
price: 19.95
bicycle*unicycle:
price: 20.25
nested:
- required: true
optional:
- first
- required: true
`
tests := []struct {
name string
Expand Down Expand Up @@ -104,6 +110,16 @@ store:
path: builder().Root().Child("store").Child(`bicycle*unicycle`).Child("price").Build(),
expected: float64(20.25),
},
{
name: "$.store.book[*].title",
path: builder().Root().Child("store").Child("book").IndexAll().Child("title").Build(),
expected: []interface{}{nil, "dictionary"},
},
{
name: "$.nested[*].optional[*]",
path: builder().Root().Child("nested").IndexAll().Child("optional").IndexAll().Build(),
expected: []interface{}{[]interface{}{"first"}, nil},
},
}
t.Run("PathString", func(t *testing.T) {
for _, test := range tests {
Expand Down

0 comments on commit 19b7508

Please sign in to comment.