MCPcopy Index your code
hub / github.com/go-openapi/jsonpointer / TestSetIntermediateErrors

Function TestSetIntermediateErrors

pointer_test.go:1182–1252  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1180}
1181
1182func TestSetIntermediateErrors(t *testing.T) {
1183 t.Parallel()
1184
1185 type leaf struct {
1186 V string `json:"v"`
1187 }
1188 type doc struct {
1189 M map[string]leaf `json:"m"`
1190 L []leaf `json:"l"`
1191 S leaf `json:"s"`
1192 N int `json:"n"`
1193 P pointableImpl `json:"p"`
1194 }
1195
1196 newDoc := func() *doc {
1197 return &doc{
1198 M: map[string]leaf{"present": {V: "x"}},
1199 L: []leaf{{V: "a"}, {V: "b"}},
1200 P: pointableImpl{a: "hello"},
1201 }
1202 }
1203
1204 cases := []struct {
1205 name string
1206 pointer string
1207 substr string
1208 }{
1209 {
1210 name: "map missing key mid-path",
1211 pointer: "/m/missing/v",
1212 substr: `no key "missing"`,
1213 },
1214 {
1215 name: "slice non-numeric index mid-path",
1216 pointer: "/l/abc/v",
1217 substr: `parsing "abc"`,
1218 },
1219 {
1220 name: "slice out-of-bounds mid-path",
1221 pointer: "/l/99/v",
1222 substr: `out of bounds`,
1223 },
1224 {
1225 name: "struct unknown field mid-path",
1226 pointer: "/s/bogus/v",
1227 substr: `no field "bogus"`,
1228 },
1229 {
1230 name: "scalar traversal mid-path",
1231 pointer: "/n/anything/v",
1232 substr: `invalid token reference "anything"`,
1233 },
1234 {
1235 name: "JSONPointable returns error mid-path",
1236 pointer: "/p/unknown/v",
1237 substr: `no field "unknown"`,
1238 },
1239 }

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
SetMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…