@@ -12,6 +12,7 @@ func TestArray_FailedChain(t *testing.T) {
12
12
value .chain .assert (t , failure )
13
13
14
14
value .Path ("$" ).chain .assert (t , failure )
15
+ value .Query ("$" ).chain .assert (t , failure )
15
16
value .Schema ("" )
16
17
value .Alias ("foo" )
17
18
@@ -239,28 +240,41 @@ func TestArray_Alias(t *testing.T) {
239
240
assert .Equal (t , []string {"foo" , "Filter()" }, childValue .chain .context .AliasedPath )
240
241
}
241
242
243
+ var jsonPathCases = []struct {
244
+ name string
245
+ value []interface {}
246
+ }{
247
+ {
248
+ name : "empty" ,
249
+ value : []interface {}{},
250
+ },
251
+ {
252
+ name : "not empty" ,
253
+ value : []interface {}{"foo" , 123.0 },
254
+ },
255
+ }
256
+
242
257
func TestArray_Path (t * testing.T ) {
243
- cases := []struct {
244
- name string
245
- value []interface {}
246
- }{
247
- {
248
- name : "empty" ,
249
- value : []interface {}{},
250
- },
251
- {
252
- name : "not empty" ,
253
- value : []interface {}{"foo" , 123.0 },
254
- },
258
+ for _ , tc := range jsonPathCases {
259
+ t .Run (tc .name , func (t * testing.T ) {
260
+ reporter := newMockReporter (t )
261
+
262
+ value := NewArray (reporter , tc .value )
263
+
264
+ assert .Equal (t , tc .value , value .Path ("$" ).Raw ())
265
+ value .chain .assert (t , success )
266
+ })
255
267
}
268
+ }
256
269
257
- for _ , tc := range cases {
270
+ func TestArray_Query (t * testing.T ) {
271
+ for _ , tc := range jsonPathCases {
258
272
t .Run (tc .name , func (t * testing.T ) {
259
273
reporter := newMockReporter (t )
260
274
261
275
value := NewArray (reporter , tc .value )
262
276
263
- assert .Equal (t , tc .value , value .Path ("$" ).Raw ())
277
+ assert .Equal (t , tc .value , value .Query ("$" ).Raw ())
264
278
value .chain .assert (t , success )
265
279
})
266
280
}
0 commit comments