MCPcopy
hub / github.com/kubernetes/client-go / TestJSONInput

Function TestJSONInput

util/jsonpath/jsonpath_test.go:201–220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

199}
200
201func TestJSONInput(t *testing.T) {
202 var pointsJSON = []byte(`[
203 {"id": "i1", "x":4, "y":-5},
204 {"id": "i2", "x":-2, "y":-5, "z":1},
205 {"id": "i3", "x": 8, "y": 3 },
206 {"id": "i4", "x": -6, "y": -1 },
207 {"id": "i5", "x": 0, "y": 2, "z": 1 },
208 {"id": "i6", "x": 1, "y": 4 }
209 ]`)
210 var pointsData interface{}
211 err := json.Unmarshal(pointsJSON, &pointsData)
212 if err != nil {
213 t.Error(err)
214 }
215 pointsTests := []jsonpathTest{
216 {"exists filter", "{[?(@.z)].id}", pointsData, "i2 i5", false},
217 {"bracket key", "{[0]['id']}", pointsData, "i1", false},
218 }
219 testJSONPath(pointsTests, false, t)
220}
221
222// TestKubernetes tests some use cases from kubernetes
223func TestKubernetes(t *testing.T) {

Callers

nothing calls this directly

Calls 2

testJSONPathFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected