(t *testing.T)
| 141 | } |
| 142 | |
| 143 | func TestFindFirstExternalAuthByExpr(t *testing.T) { |
| 144 | t.Parallel() |
| 145 | |
| 146 | app, _ := tests.NewTestApp() |
| 147 | defer app.Cleanup() |
| 148 | |
| 149 | scenarios := []struct { |
| 150 | expr dbx.Expression |
| 151 | expectedId string |
| 152 | }{ |
| 153 | {dbx.HashExp{"collectionRef": "invalid"}, ""}, |
| 154 | {dbx.HashExp{"collectionRef": "_pb_users_auth_"}, "5eto7nmys833164"}, |
| 155 | {dbx.HashExp{"collectionRef": "_pb_users_auth_", "provider": "gitlab"}, "dlmflokuq1xl342"}, |
| 156 | } |
| 157 | |
| 158 | for i, s := range scenarios { |
| 159 | t.Run(fmt.Sprintf("%d_%v", i, s.expr.Build(app.ConcurrentDB().(*dbx.DB), dbx.Params{})), func(t *testing.T) { |
| 160 | result, err := app.FindFirstExternalAuthByExpr(s.expr) |
| 161 | |
| 162 | hasErr := err != nil |
| 163 | expectErr := s.expectedId == "" |
| 164 | if hasErr != expectErr { |
| 165 | t.Fatalf("Expected hasErr %v, got %v", expectErr, hasErr) |
| 166 | } |
| 167 | |
| 168 | if hasErr { |
| 169 | return |
| 170 | } |
| 171 | |
| 172 | if result.Id != s.expectedId { |
| 173 | t.Errorf("Expected id %q, got %q", s.expectedId, result.Id) |
| 174 | } |
| 175 | }) |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | func TestDeleteAllExternalAuthsByRecord(t *testing.T) { |
| 180 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…