MCPcopy
hub / github.com/pocketbase/pocketbase / TestModelQuery

Function TestModelQuery

core/db_test.go:32–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestModelQuery(t *testing.T) {
33 t.Parallel()
34
35 app, _ := tests.NewTestApp()
36 defer app.Cleanup()
37
38 modelsQuery := app.ModelQuery(&core.Collection{})
39 logsModelQuery := app.AuxModelQuery(&core.Collection{})
40
41 if app.ConcurrentDB() == modelsQuery.Info().Builder {
42 t.Fatalf("ModelQuery() is not using app.ConcurrentDB()")
43 }
44
45 if app.AuxConcurrentDB() == logsModelQuery.Info().Builder {
46 t.Fatalf("AuxModelQuery() is not using app.AuxConcurrentDB()")
47 }
48
49 expectedSQL := "SELECT {{_collections}}.* FROM `_collections`"
50 for i, q := range []*dbx.SelectQuery{modelsQuery, logsModelQuery} {
51 sql := q.Build().SQL()
52 if sql != expectedSQL {
53 t.Fatalf("[%d] Expected select\n%s\ngot\n%s", i, expectedSQL, sql)
54 }
55 }
56}
57
58func TestValidate(t *testing.T) {
59 t.Parallel()

Callers

nothing calls this directly

Calls 7

CleanupMethod · 0.95
NewTestAppFunction · 0.92
ModelQueryMethod · 0.65
AuxModelQueryMethod · 0.65
ConcurrentDBMethod · 0.65
AuxConcurrentDBMethod · 0.65
BuildMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…