MCPcopy
hub / github.com/pocketbase/pocketbase / TestGetOk

Function TestGetOk

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

Source from the content-addressed store, hash-verified

150}
151
152func TestGetOk(t *testing.T) {
153 s := store.New(map[string]int{"test1": 0, "test2": 1})
154
155 scenarios := []struct {
156 key string
157 expectValue int
158 expectOk bool
159 }{
160 {"test1", 0, true},
161 {"test2", 1, true},
162 {"missing", 0, false}, // should auto fallback to the zero value
163 }
164
165 for _, scenario := range scenarios {
166 t.Run(scenario.key, func(t *testing.T) {
167 val, ok := s.GetOk(scenario.key)
168
169 if ok != scenario.expectOk {
170 t.Fatalf("Expected ok %v, got %v", scenario.expectOk, ok)
171 }
172
173 if val != scenario.expectValue {
174 t.Fatalf("Expected %v, got %v", scenario.expectValue, val)
175 }
176 })
177 }
178}
179
180func TestGetAll(t *testing.T) {
181 data := map[string]int{

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
GetOkMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…