MCPcopy
hub / github.com/pocketbase/pocketbase / TestFindFirstExternalAuthByExpr

Function TestFindFirstExternalAuthByExpr

core/external_auth_query_test.go:143–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

141}
142
143func 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
179func TestDeleteAllExternalAuthsByRecord(t *testing.T) {
180 t.Parallel()

Callers

nothing calls this directly

Calls 6

CleanupMethod · 0.95
NewTestAppFunction · 0.92
ConcurrentDBMethod · 0.65
RunMethod · 0.45
BuildMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…