MCPcopy
hub / github.com/pocketbase/pocketbase / TestRecordUpsertSubmitValidations

Function TestRecordUpsertSubmitValidations

forms/record_upsert_test.go:440–762  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

438}
439
440func TestRecordUpsertSubmitValidations(t *testing.T) {
441 t.Parallel()
442
443 app, _ := tests.NewTestApp()
444 defer app.Cleanup()
445
446 demo2Col, err := app.FindCollectionByNameOrId("demo2")
447 if err != nil {
448 t.Fatal(err)
449 }
450
451 demo2Rec, err := app.FindRecordById(demo2Col, "llvuca81nly1qls")
452 if err != nil {
453 t.Fatal(err)
454 }
455
456 usersCol, err := app.FindCollectionByNameOrId("users")
457 if err != nil {
458 t.Fatal(err)
459 }
460
461 userRec, err := app.FindRecordById(usersCol, "4q1xlclmfloku33")
462 if err != nil {
463 t.Fatal(err)
464 }
465
466 scenarios := []struct {
467 name string
468 record *core.Record
469 data map[string]any
470 managerAccess bool
471 expectedErrors []string
472 }{
473 // base
474 {
475 name: "new base collection record with empty data",
476 record: core.NewRecord(demo2Col),
477 data: map[string]any{},
478 expectedErrors: []string{"title"},
479 },
480 {
481 name: "new base collection record with invalid data",
482 record: core.NewRecord(demo2Col),
483 data: map[string]any{
484 "title": "",
485 // should be ignored
486 "custom": "abc",
487 "oldPassword": "123",
488 "password": "456",
489 "passwordConfirm": "789",
490 },
491 expectedErrors: []string{"title"},
492 },
493 {
494 name: "new base collection record with valid data",
495 record: core.NewRecord(demo2Col),
496 data: map[string]any{
497 "title": "abc",

Callers

nothing calls this directly

Calls 12

CleanupMethod · 0.95
GrantManagerAccessMethod · 0.95
LoadMethod · 0.95
SubmitMethod · 0.95
NewTestAppFunction · 0.92
NewRecordFunction · 0.92
NewRecordUpsertFunction · 0.92
TestValidationErrorsFunction · 0.92
OriginalMethod · 0.80
FindRecordByIdMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…