(t *testing.T)
| 438 | } |
| 439 | |
| 440 | func 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", |
nothing calls this directly
no test coverage detected
searching dependent graphs…