(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func 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-"`, |
nothing calls this directly
no test coverage detected
searching dependent graphs…