MCPcopy
hub / github.com/pocketbase/pocketbase / testDefaultFieldNameValidation

Function testDefaultFieldNameValidation

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

Source from the content-addressed store, hash-verified

122}
123
124func testDefaultFieldNameValidation(t *testing.T, fieldType string) {
125 app, _ := tests.NewTestApp()
126 defer app.Cleanup()
127
128 collection := core.NewBaseCollection("test_collection")
129
130 scenarios := []struct {
131 name string
132 field func() core.Field
133 expectError bool
134 }{
135 {
136 "empty value",
137 func() core.Field {
138 f := core.Fields[fieldType]()
139 return f
140 },
141 true,
142 },
143 {
144 "invalid length",
145 func() core.Field {
146 f := core.Fields[fieldType]()
147 f.SetName(strings.Repeat("a", 101))
148 return f
149 },
150 true,
151 },
152 {
153 "valid length",
154 func() core.Field {
155 f := core.Fields[fieldType]()
156 f.SetName(strings.Repeat("a", 100))
157 return f
158 },
159 false,
160 },
161 {
162 "invalid regex",
163 func() core.Field {
164 f := core.Fields[fieldType]()
165 f.SetName("test(")
166 return f
167 },
168 true,
169 },
170 {
171 "valid regex",
172 func() core.Field {
173 f := core.Fields[fieldType]()
174 f.SetName("test_123")
175 return f
176 },
177 false,
178 },
179 {
180 "_via_",
181 func() core.Field {

Calls 6

CleanupMethod · 0.95
NewTestAppFunction · 0.92
NewBaseCollectionFunction · 0.92
SetNameMethod · 0.65
ValidateSettingsMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…