MCPcopy
hub / github.com/pocketbase/pocketbase / TestReset

Function TestReset

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

Source from the content-addressed store, hash-verified

41}
42
43func TestReset(t *testing.T) {
44 s := store.New(map[string]int{"test1": 1})
45
46 data := map[string]int{"test2": 2}
47 originalRawData, err := json.Marshal(data)
48 if err != nil {
49 t.Fatal(err)
50 }
51
52 s.Reset(data)
53 s.Set("test3", 3)
54
55 // check if data was shallow copied
56 rawData, _ := json.Marshal(data)
57 if !bytes.Equal(originalRawData, rawData) {
58 t.Fatalf("Expected data \n%s, \ngot \n%s", originalRawData, rawData)
59 }
60
61 if s.Has("test1") {
62 t.Fatalf("Expected test1 to be deleted, got %v", s.Get("test1"))
63 }
64
65 if v := s.Get("test2"); v != 2 {
66 t.Fatalf("Expected test2 to be %v, got %v", 2, v)
67 }
68
69 if v := s.Get("test3"); v != 3 {
70 t.Fatalf("Expected test3 to be %v, got %v", 3, v)
71 }
72}
73
74func TestLength(t *testing.T) {
75 s := store.New(map[string]int{"test1": 1})

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
SetMethod · 0.65
EqualMethod · 0.65
GetMethod · 0.65
ResetMethod · 0.45
HasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…