MCPcopy
hub / github.com/pocketbase/pocketbase / TestTextFieldValidateSettings

Function TestTextFieldValidateSettings

core/field_text_test.go:381–583  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

379}
380
381func TestTextFieldValidateSettings(t *testing.T) {
382 testDefaultFieldIdValidation(t, core.FieldTypeText)
383 testDefaultFieldNameValidation(t, core.FieldTypeText)
384 testDefaultFieldHelpValidation[core.TextField](t)
385
386 app, _ := tests.NewTestApp()
387 defer app.Cleanup()
388
389 scenarios := []struct {
390 name string
391 field func() *core.TextField
392 expectErrors []string
393 }{
394 {
395 "zero minimal",
396 func() *core.TextField {
397 return &core.TextField{
398 Id: "test",
399 Name: "test",
400 }
401 },
402 []string{},
403 },
404 {
405 "primaryKey without required",
406 func() *core.TextField {
407 return &core.TextField{
408 Id: "test",
409 Name: "id",
410 PrimaryKey: true,
411 Pattern: `\d+`,
412 }
413 },
414 []string{"required"},
415 },
416 {
417 "primaryKey without pattern",
418 func() *core.TextField {
419 return &core.TextField{
420 Id: "test",
421 Name: "id",
422 PrimaryKey: true,
423 Required: true,
424 }
425 },
426 []string{"pattern"},
427 },
428 {
429 "primaryKey with hidden",
430 func() *core.TextField {
431 return &core.TextField{
432 Id: "test",
433 Name: "id",
434 Required: true,
435 PrimaryKey: true,
436 Hidden: true,
437 Pattern: `\d+`,
438 }

Callers

nothing calls this directly

Calls 11

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