MCPcopy
hub / github.com/pocketbase/pocketbase / TestUnmarshalJSON

Function TestUnmarshalJSON

tools/store/store_test.go:344–365  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

342}
343
344func TestUnmarshalJSON(t *testing.T) {
345 s := store.Store[string, string]{}
346 s.Set("b", "old") // should be overwritten
347 s.Set("c", "test3") // ensures that the old values are not removed
348
349 raw := []byte(`{"a":"test1", "b":"test2"}`)
350 if err := json.Unmarshal(raw, &s); err != nil {
351 t.Fatal(err)
352 }
353
354 if v := s.Get("a"); v != "test1" {
355 t.Fatalf("Expected store.a to be %q, got %q", "test1", v)
356 }
357
358 if v := s.Get("b"); v != "test2" {
359 t.Fatalf("Expected store.b to be %q, got %q", "test2", v)
360 }
361
362 if v := s.Get("c"); v != "test3" {
363 t.Fatalf("Expected store.c to be %q, got %q", "test3", v)
364 }
365}
366
367func TestMarshalJSON(t *testing.T) {
368 s := &store.Store[string, string]{}

Callers

nothing calls this directly

Calls 2

SetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…