mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-10 03:19:44 +00:00
Fix bug in JSON path parser where an error occurs when a range is empty
Kubernetes-commit: 10634c6093c84acc78181a26c93d8785e12802e4
This commit is contained in:
committed by
Kubernetes Publisher
parent
4ef01cd5e2
commit
135cef183c
@@ -393,6 +393,21 @@ func TestKubernetes(t *testing.T) {
|
||||
testJSONPathSortOutput(randomPrintOrderTests, t)
|
||||
}
|
||||
|
||||
func TestEmptyRange(t *testing.T) {
|
||||
var input = []byte(`{"items":[]}`)
|
||||
var emptyList interface{}
|
||||
err := json.Unmarshal(input, &emptyList)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
tests := []jsonpathTest{
|
||||
{"empty range", `{range .items[*]}{.metadata.name}{end}`, &emptyList, "", false},
|
||||
{"empty nested range", `{range .items[*]}{.metadata.name}{":"}{range @.spec.containers[*]}{.name}{","}{end}{"+"}{end}`, &emptyList, "", false},
|
||||
}
|
||||
testJSONPath(tests, true, t)
|
||||
}
|
||||
|
||||
func TestNestedRanges(t *testing.T) {
|
||||
var input = []byte(`{
|
||||
"items": [
|
||||
|
Reference in New Issue
Block a user