Documentation
¶
Index ¶
- func IsSpanner[DB WithDriver](db *sql.DB) bool
- func IsSqlite[DB WithDriver](db *sql.DB) bool
- func RecreateSchema(ctx context.Context, t *testing.T, db SchemaHandler)
- func RecreateSchemaOnce(ctx context.Context, db SchemaHandler) (err error)
- func RunDBTest[T TestDB](t *testing.T, open func(driver string, source string) (db T, err error), ...)
- type SchemaHandler
- type T
- type TestDB
- type WithDriver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSpanner ¶
func IsSpanner[DB WithDriver](db *sql.DB) bool
IsSpanner returns true of the db is a spanner db.
func IsSqlite ¶
func IsSqlite[DB WithDriver](db *sql.DB) bool
IsSqlite returns true of the db is a sqlite db.
func RecreateSchema ¶
func RecreateSchema(ctx context.Context, t *testing.T, db SchemaHandler)
RecreateSchema will drop and recreate schema. Will try it with multiple times with increased sleep time. To void errors like "Schema change operation rejected because a concurrent schema change operation or read-write transaction is already in progress.".
func RecreateSchemaOnce ¶
func RecreateSchemaOnce(ctx context.Context, db SchemaHandler) (err error)
RecreateSchemaOnce will drop and recreate schema.
Types ¶
type SchemaHandler ¶
type SchemaHandler interface {
Schema() []string
DropSchema() []string
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}
SchemaHandler contains methods required for a schema recreation.
type WithDriver ¶
WithDriver represents a DB which has a driver (usually *sql.DB).
Click to show internal directories.
Click to hide internal directories.