MCPcopy
hub / github.com/pocketbase/pocketbase / testFieldBaseMethods

Function testFieldBaseMethods

core/field_test.go:15–71  ·  view source on GitHub ↗
(t *testing.T, fieldType string)

Source from the content-addressed store, hash-verified

13)
14
15func testFieldBaseMethods(t *testing.T, fieldType string) {
16 factory, ok := core.Fields[fieldType]
17 if !ok {
18 t.Fatalf("Missing %q field factory", fieldType)
19 }
20
21 f := factory()
22 if f == nil {
23 t.Fatal("Expected non-nil Field instance")
24 }
25
26 t.Run("type", func(t *testing.T) {
27 if v := f.Type(); v != fieldType {
28 t.Fatalf("Expected type %q, got %q", fieldType, v)
29 }
30 })
31
32 t.Run("id", func(t *testing.T) {
33 testValues := []string{"new_id", ""}
34 for _, expected := range testValues {
35 f.SetId(expected)
36 if v := f.GetId(); v != expected {
37 t.Fatalf("Expected id %q, got %q", expected, v)
38 }
39 }
40 })
41
42 t.Run("name", func(t *testing.T) {
43 testValues := []string{"new_name", ""}
44 for _, expected := range testValues {
45 f.SetName(expected)
46 if v := f.GetName(); v != expected {
47 t.Fatalf("Expected name %q, got %q", expected, v)
48 }
49 }
50 })
51
52 t.Run("system", func(t *testing.T) {
53 testValues := []bool{false, true}
54 for _, expected := range testValues {
55 f.SetSystem(expected)
56 if v := f.GetSystem(); v != expected {
57 t.Fatalf("Expected system %v, got %v", expected, v)
58 }
59 }
60 })
61
62 t.Run("hidden", func(t *testing.T) {
63 testValues := []bool{false, true}
64 for _, expected := range testValues {
65 f.SetHidden(expected)
66 if v := f.GetHidden(); v != expected {
67 t.Fatalf("Expected hidden %v, got %v", expected, v)
68 }
69 }
70 })
71}
72

Calls 10

TypeMethod · 0.65
SetIdMethod · 0.65
GetIdMethod · 0.65
SetNameMethod · 0.65
GetNameMethod · 0.65
SetSystemMethod · 0.65
GetSystemMethod · 0.65
SetHiddenMethod · 0.65
GetHiddenMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…