MCPcopy
hub / github.com/bitly/go-simplejson / TestSetPathNoPath

Function TestSetPathNoPath

simplejson_test.go:261–284  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

259}
260
261func TestSetPathNoPath(t *testing.T) {
262 js, err := NewJson([]byte(`{"some":"data","some_number":1.0,"some_bool":false}`))
263 if err != nil {
264 t.Fatalf("err %#v", err)
265 }
266
267 if f := js.GetPath("some_number").MustFloat64(99.0); f != 1.0 {
268 t.Errorf("got %#v", f)
269 }
270
271 js.SetPath([]string{}, map[string]interface{}{"foo": "bar"})
272
273 s, err := js.GetPath("foo").String()
274 if err != nil {
275 t.Fatalf("err %#v", err)
276 }
277 if s != "bar" {
278 t.Errorf("got %#v", s)
279 }
280
281 if f := js.GetPath("some_number").MustFloat64(99.0); f != 99.0 {
282 t.Errorf("got %#v", f)
283 }
284}
285
286func TestPathWillAugmentExisting(t *testing.T) {
287 js, err := NewJson([]byte(`{"this":{"a":"aa","b":"bb","c":"cc"}}`))

Callers

nothing calls this directly

Calls 5

GetPathMethod · 0.95
SetPathMethod · 0.95
NewJsonFunction · 0.85
MustFloat64Method · 0.80
StringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…