mirror of https://github.com/k3s-io/k3s
Fix struct input test in jsonpath
parent
1313e3b14e
commit
5f3aff2c43
|
@ -217,7 +217,7 @@ func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect.
|
||||||
|
|
||||||
value, isNil := template.Indirect(value)
|
value, isNil := template.Indirect(value)
|
||||||
if isNil || (value.Kind() != reflect.Array && value.Kind() != reflect.Slice) {
|
if isNil || (value.Kind() != reflect.Array && value.Kind() != reflect.Slice) {
|
||||||
return input, fmt.Errorf("%v is not array or slice", value)
|
return input, fmt.Errorf("%v is not array or slice", value.Type())
|
||||||
}
|
}
|
||||||
params := node.Params
|
params := node.Params
|
||||||
if !params[0].Known {
|
if !params[0].Known {
|
||||||
|
|
|
@ -162,7 +162,7 @@ func TestStructInput(t *testing.T) {
|
||||||
failStoreTests := []jsonpathTest{
|
failStoreTests := []jsonpathTest{
|
||||||
{"invalid identfier", "{hello}", storeData, "unrecongnized identifier hello"},
|
{"invalid identfier", "{hello}", storeData, "unrecongnized identifier hello"},
|
||||||
{"nonexistent field", "{.hello}", storeData, "hello is not found"},
|
{"nonexistent field", "{.hello}", storeData, "hello is not found"},
|
||||||
{"invalid array", "{.Labels[0]}", storeData, "<map[string]int Value> is not array or slice"},
|
{"invalid array", "{.Labels[0]}", storeData, "map[string]int is not array or slice"},
|
||||||
{"invalid filter operator", "{.Book[?(@.Price<>10)]}", storeData, "unrecognized filter operator <>"},
|
{"invalid filter operator", "{.Book[?(@.Price<>10)]}", storeData, "unrecognized filter operator <>"},
|
||||||
{"redundent end", "{range .Labels.*}{@}{end}{end}", storeData, "not in range, nothing to end"},
|
{"redundent end", "{range .Labels.*}{@}{end}{end}", storeData, "not in range, nothing to end"},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue