MCPcopy
hub / github.com/pocketbase/pocketbase / TestRecordUpsertLoad

Function TestRecordUpsertLoad

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

Source from the content-addressed store, hash-verified

17)
18
19func TestRecordUpsertLoad(t *testing.T) {
20 t.Parallel()
21
22 testApp, _ := tests.NewTestApp()
23 defer testApp.Cleanup()
24
25 demo1Col, err := testApp.FindCollectionByNameOrId("demo1")
26 if err != nil {
27 t.Fatal(err)
28 }
29
30 usersCol, err := testApp.FindCollectionByNameOrId("users")
31 if err != nil {
32 t.Fatal(err)
33 }
34
35 file, err := filesystem.NewFileFromBytes([]byte("test"), "test.txt")
36 if err != nil {
37 t.Fatal(err)
38 }
39
40 scenarios := []struct {
41 name string
42 data map[string]any
43 record *core.Record
44 managerAccessLevel bool
45 superuserAccessLevel bool
46 expected []string
47 notExpected []string
48 }{
49 {
50 name: "base collection record",
51 data: map[string]any{
52 "text": "test_text",
53 "custom": "123", // should be ignored
54 "number": "456", // should be normalized by the setter
55 "select_many+": []string{"optionB", "optionC"}, // test modifier fields
56 "created": "2022-01:01 10:00:00.000Z", // should be ignored
57 // ignore special auth fields
58 "oldPassword": "123",
59 "password": "456",
60 "passwordConfirm": "789",
61 },
62 record: core.NewRecord(demo1Col),
63 expected: []string{
64 `"text":"test_text"`,
65 `"number":456`,
66 `"select_many":["optionB","optionC"]`,
67 `"created":""`,
68 `"updated":""`,
69 `"json":null`,
70 },
71 notExpected: []string{
72 `"custom"`,
73 `"password"`,
74 `"oldPassword"`,
75 `"passwordConfirm"`,
76 `"select_many-"`,

Callers

nothing calls this directly

Calls 14

CleanupMethod · 0.95
GrantManagerAccessMethod · 0.95
GrantSuperuserAccessMethod · 0.95
HasManageAccessMethod · 0.95
LoadMethod · 0.95
NewTestAppFunction · 0.92
NewFileFromBytesFunction · 0.92
NewRecordFunction · 0.92
NewRecordUpsertFunction · 0.92
FieldsDataMethod · 0.80
CustomDataMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…