MCPcopy
hub / github.com/pocketbase/pocketbase / TestSelectFieldValidateSettings

Function TestSelectFieldValidateSettings

core/field_select_test.go:337–398  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

335}
336
337func TestSelectFieldValidateSettings(t *testing.T) {
338 testDefaultFieldIdValidation(t, core.FieldTypeSelect)
339 testDefaultFieldNameValidation(t, core.FieldTypeSelect)
340 testDefaultFieldHelpValidation[core.SelectField](t)
341
342 app, _ := tests.NewTestApp()
343 defer app.Cleanup()
344
345 scenarios := []struct {
346 name string
347 field func() *core.SelectField
348 expectErrors []string
349 }{
350 {
351 "zero minimal",
352 func() *core.SelectField {
353 return &core.SelectField{
354 Id: "test",
355 Name: "test",
356 }
357 },
358 []string{"values"},
359 },
360 {
361 "MaxSelect > Values length",
362 func() *core.SelectField {
363 return &core.SelectField{
364 Id: "test",
365 Name: "test",
366 Values: []string{"a", "b"},
367 MaxSelect: 3,
368 }
369 },
370 []string{"maxSelect"},
371 },
372 {
373 "MaxSelect <= Values length",
374 func() *core.SelectField {
375 return &core.SelectField{
376 Id: "test",
377 Name: "test",
378 Values: []string{"a", "b"},
379 MaxSelect: 2,
380 }
381 },
382 []string{},
383 },
384 }
385
386 for _, s := range scenarios {
387 t.Run(s.name, func(t *testing.T) {
388 field := s.field()
389
390 collection := core.NewBaseCollection("test_collection")
391 collection.Fields.Add(field)
392
393 errs := field.ValidateSettings(context.Background(), app, collection)
394

Callers

nothing calls this directly

Calls 9

CleanupMethod · 0.95
NewTestAppFunction · 0.92
NewBaseCollectionFunction · 0.92
TestValidationErrorsFunction · 0.92
ValidateSettingsMethod · 0.65
RunMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…