MCPcopy
hub / github.com/pocketbase/pocketbase / TestBoolFieldPrepareValue

Function TestBoolFieldPrepareValue

core/field_bool_test.go:29–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27}
28
29func TestBoolFieldPrepareValue(t *testing.T) {
30 app, _ := tests.NewTestApp()
31 defer app.Cleanup()
32
33 f := &core.BoolField{}
34 record := core.NewRecord(core.NewBaseCollection("test"))
35
36 scenarios := []struct {
37 raw any
38 expected bool
39 }{
40 {"", false},
41 {"f", false},
42 {"t", true},
43 {1, true},
44 {0, false},
45 }
46
47 for i, s := range scenarios {
48 t.Run(fmt.Sprintf("%d_%#v", i, s.raw), func(t *testing.T) {
49 v, err := f.PrepareValue(record, s.raw)
50 if err != nil {
51 t.Fatal(err)
52 }
53
54 if v != s.expected {
55 t.Fatalf("Expected %v, got %v", s.expected, v)
56 }
57 })
58 }
59}
60
61func TestBoolFieldValidateValue(t *testing.T) {
62 app, _ := tests.NewTestApp()

Callers

nothing calls this directly

Calls 6

CleanupMethod · 0.95
PrepareValueMethod · 0.95
NewTestAppFunction · 0.92
NewRecordFunction · 0.92
NewBaseCollectionFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…