testrun

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

func Run

func Run(ctx context.Context, p *project.Project, only ...string) ([]Result, error)

Run runs the project's tests, each against its own fresh database with the seed data, in a temporary directory: the project's .supacraft is never touched. No email is sent and no network call is made. only, when not empty, picks the tests to run by name.

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.

func SeedLocal

func SeedLocal(ctx context.Context, p *project.Project, reset bool) (*SeedResult, error)

SeedLocal applies the project to its own .supacraft database and adds the seed data. With reset it first deletes every row of the project's tables (users and their tokens included; uploaded files stay), so the database holds exactly the seed. A running dev server keeps working.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL