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 ApproveE2E(t *testing.T, store db.Store, userID, storageID int64, path, kind string) *model.E2ERequest
- func E2EStatus(t *testing.T, store db.Store, id int64) string
- 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 SettingFails(store db.Store, key string, err error) db.Store
- func TmpFilePath(t *testing.T, name string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApproveE2E ¶ added in v0.51.0
func ApproveE2E(t *testing.T, store db.Store, userID, storageID int64, path, kind string) *model.E2ERequest
ApproveE2E leaves what the requests service leaves when an administrator approves userID's request to encrypt as kind (model.E2ERequestFolder or E2ERequestFile) at path on storageID: an approved row, good for a day. path is where the rule looks for it (e2epolicy.ApprovalPath): the folder itself for an encrypted folder, the folder a `.fxe` goes into for a file.
func E2EStatus ¶ added in v0.51.0
E2EStatus is request id's status now: approved until a create spends it, used after.
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.
func SettingFails ¶ added in v0.51.0
SettingFails is store with one setting that cannot be read: GetSetting(key) answers err, and everything else is store's own. It is how a test makes a decision that reads a setting (e2e.policy, say) undecidable.
Types ¶
This section is empty.