@@ -12,6 +12,7 @@ func TestArray_FailedChain(t *testing.T) {
1212 value .chain .assert (t , failure )
1313
1414 value .Path ("$" ).chain .assert (t , failure )
15+ value .Query ("$" ).chain .assert (t , failure )
1516 value .Schema ("" )
1617 value .Alias ("foo" )
1718
@@ -239,28 +240,41 @@ func TestArray_Alias(t *testing.T) {
239240 assert .Equal (t , []string {"foo" , "Filter()" }, childValue .chain .context .AliasedPath )
240241}
241242
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+
242257func 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+ })
255267 }
268+ }
256269
257- for _ , tc := range cases {
270+ func TestArray_Query (t * testing.T ) {
271+ for _ , tc := range jsonPathCases {
258272 t .Run (tc .name , func (t * testing.T ) {
259273 reporter := newMockReporter (t )
260274
261275 value := NewArray (reporter , tc .value )
262276
263- assert .Equal (t , tc .value , value .Path ("$" ).Raw ())
277+ assert .Equal (t , tc .value , value .Query ("$" ).Raw ())
264278 value .chain .assert (t , success )
265279 })
266280 }
0 commit comments