MCPcopy
hub / github.com/pocketbase/pocketbase / TestJSONFieldValidateSettings

Function TestJSONFieldValidateSettings

core/field_json_test.go:188–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

186}
187
188func TestJSONFieldValidateSettings(t *testing.T) {
189 testDefaultFieldIdValidation(t, core.FieldTypeJSON)
190 testDefaultFieldNameValidation(t, core.FieldTypeJSON)
191 testDefaultFieldHelpValidation[core.JSONField](t)
192
193 app, _ := tests.NewTestApp()
194 defer app.Cleanup()
195
196 collection := core.NewBaseCollection("test_collection")
197
198 scenarios := []struct {
199 name string
200 field func() *core.JSONField
201 expectErrors []string
202 }{
203 {
204 "MaxSize < 0",
205 func() *core.JSONField {
206 return &core.JSONField{
207 Id: "test",
208 Name: "test",
209 MaxSize: -1,
210 }
211 },
212 []string{"maxSize"},
213 },
214 {
215 "MaxSize = 0",
216 func() *core.JSONField {
217 return &core.JSONField{
218 Id: "test",
219 Name: "test",
220 }
221 },
222 []string{},
223 },
224 {
225 "MaxSize > 0",
226 func() *core.JSONField {
227 return &core.JSONField{
228 Id: "test",
229 Name: "test",
230 MaxSize: 1,
231 }
232 },
233 []string{},
234 },
235 {
236 "MaxSize > safe json int",
237 func() *core.JSONField {
238 return &core.JSONField{
239 Id: "test",
240 Name: "test",
241 MaxSize: 1 << 53,
242 }
243 },
244 []string{"maxSize"},
245 },

Callers

nothing calls this directly

Calls 8

CleanupMethod · 0.95
NewTestAppFunction · 0.92
NewBaseCollectionFunction · 0.92
TestValidationErrorsFunction · 0.92
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…