Documentation ¶
Index ¶
- func MustCreateDB(pgURL, dbName string)
- func MustDropDB(pgURL, dbName string)
- func MustOpen(pgURL string) *sql.DB
- func MustSelectDB(pgURL, dbName string) string
- func ResetProfiler(ctx context.Context, functionNames ...string)
- type Helper
- func (h *Helper) AfterSuite(ctx context.Context, t *testing.T)
- func (h *Helper) BeforeSuite(ctx context.Context, t *testing.T) context.Context
- func (h *Helper) BeforeTest(ctx context.Context, t *testing.T) context.Context
- func (h *Helper) GetNow(ctx context.Context) time.Time
- func (h *Helper) SetNow(ctx context.Context, t time.Time) time.Time
- type Profile
- type ProfileByLine
- type ProfileByStatement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustCreateDB ¶
func MustCreateDB(pgURL, dbName string)
MustCreateDB creates (or recreates) a Postgres database, panics on error.
func MustDropDB ¶
func MustDropDB(pgURL, dbName string)
MustDropDB drops a Postgres database, panics on error.
func MustSelectDB ¶
MustSelectDB returns a new pgURL with the given DB name, panics on error.
func ResetProfiler ¶
ResetProfiler resets the database profiler data for the given functions.
Types ¶
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper is a test helper for PG.
func (*Helper) AfterSuite ¶
AfterSuite implements fixturez.AfterSuite.
func (*Helper) BeforeSuite ¶
BeforeSuite implements fixturez.BeforeSuite.
func (*Helper) BeforeTest ¶
BeforeTest implements fixtures.BeforeTest.
type Profile ¶
type Profile struct { FunctionName string StatementsTotal float64 `db:"statements_total" header:"Statements Total"` BranchesTotal float64 `db:"branches_total" header:"Branches Total"` ByLine []*ProfileByLine ByStatement []*ProfileByStatement }
Profile describes a database profile.
func GetProfile ¶
GetProfile returns a database profile for the given function.
func (*Profile) PrettyPrint ¶
func (p *Profile) PrettyPrint()
PrettyPrint pretty prints the Profile.
func (*Profile) RequireCoverage ¶
RequireCoverage requires the specified coverage.
func (*Profile) RequireFullCoverage ¶
RequireFullCoverage requires full coverage.
type ProfileByLine ¶
type ProfileByLine struct { LineNumber int64 `db:"lineno" header:"Line Number"` ExecStatements int64 `db:"exec_stmts" header:"Exec Stmts"` Source string `db:"source" header:"Source"` }
ProfileByLine describes a per-line database profile.
type ProfileByStatement ¶
type ProfileByStatement struct { StatementID int64 `db:"stmtid" header:"Stmt ID"` ParentStatementID int64 `db:"parent_stmtid" header:"Parent Stmt ID"` ParentNote string `db:"parent_note" header:"Parent Note"` LineNumber int64 `db:"lineno" header:"Line Number"` ExecStatements int64 `db:"exec_stmts" header:"Exec Stmts"` StatementName string `db:"stmtname" header:"Stmt Name"` }
ProfileByStatement describes a per-statement database profile.