Documentation
¶
Overview ¶
Package dbtest provides minimal DB+model test helpers without depending on auth/capability/share — so it is safe to import from the test files of those packages without creating an import cycle.
If you need a full HTTP server harness (auth wiring, share service, capability probes), use internal/testutil instead.
Index ¶
- func NewTestDB(t *testing.T) (*sql.DB, db.Store)
- func ReadJSON(t *testing.T, resp *http.Response, out any)
- func SeedAdmin(t *testing.T, store db.Store) (string, string)
- func SeedRegularUser(t *testing.T, store db.Store, email, password string)
- func SeedUserWithRole(t *testing.T, store db.Store, email, password, role string) int64
- func TmpFilePath(t *testing.T, name string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestDB ¶
NewTestDB opens an in-memory SQLite DB, runs all migrations, and returns the underlying *sql.DB plus a typed Store. Cleanup is registered via t.Cleanup so tests don't have to remember to close.
func SeedAdmin ¶
SeedAdmin creates an admin user with a known password and returns the (email, plaintext password) tuple suitable for downstream login helpers.
func SeedRegularUser ¶
SeedRegularUser creates a non-admin user with the supplied credentials.
func SeedUserWithRole ¶
SeedUserWithRole creates a user with an explicit role and returns the generated user ID. Useful when tests need a specific role beyond the two helpers above.
Types ¶
This section is empty.