Documentation
¶
Overview ¶
Package testrun loads a project's seed data and runs its tests (the "seed" and "tests" sections of supacraft.json).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
Name string `json:"name"`
Passed bool `json:"passed"`
Status int `json:"status,omitempty"`
Failures []string `json:"failures,omitempty"`
// Body is the response body, kept for failed tests.
Body string `json:"body,omitempty"`
// ServerErrors are the internal errors the request logged (5xx).
ServerErrors []string `json:"server_errors,omitempty"`
}
Result is the outcome of one test.
type SeedResult ¶
type SeedResult struct {
Users int `json:"users_added"`
// Rows counts added rows per table.
Rows map[string]int `json:"rows_added"`
// Skipped lists tables without a primary key that already had rows
// (their seed rows are only added to an empty table).
Skipped []string `json:"skipped,omitempty"`
}
SeedResult says what a seed added.
func Seed ¶
func Seed(ctx context.Context, db *sql.DB, cfg *tenant.TenantConfig, seed *project.Seed, env func(string) (string, bool)) (*SeedResult, error)
Seed adds the seed data to db. It can run again: users are matched by email and rows by primary key (a row without one gets an id derived from its table and position), so existing data is never duplicated or changed. env resolves "${NAME}" passwords.