Documentation
¶
Overview ¶
Package dialects holds the schema dialect fact probes of docs/spec/dialects.md.
Each probe states one observable fact about MySQL, PostgreSQL or SQLite, runs DDL, DML and catalog queries in its own disposable database, schema or file, and fails when the database does not behave as stated. The physical test in facts_physical_test.go runs every probe with its own deadline.
Index ¶
- func ErrorCode(err error) string
- func ScanCells(rows *sql.Rows, n int) ([]string, error)
- func Validate(probes []Probe) error
- type Env
- func (e *Env) Check(ok bool, format string, args ...any)
- func (e *Env) Column(query string, args ...any) string
- func (e *Env) Exec(statements ...string)
- func (e *Env) ExecArgs(statement string, args ...any)
- func (e *Env) Fails(statement, want string, args ...any)
- func (e *Env) FailsAny(statement string, args ...any)
- func (e *Env) Merge(other *Env)
- func (e *Env) Note(format string, args ...any)
- func (e *Env) Other() *Env
- func (e *Env) Value(query string, args ...any) string
- func (e *Env) Want(query, want string, args ...any)
- func (e *Env) WantRows(query, want string, args ...any)
- type Probe
- type ProbeFixture
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorCode ¶
ErrorCode returns the MySQL error number, the PostgreSQL SQLSTATE or the SQLite message of an error.
Types ¶
type Env ¶
type Env struct {
Ctx context.Context
Conn *sql.Conn
DB string
Name string // database, schema or file of this probe
Session func() (*Env, error)
// Second creates the probe's second database, schema or file, named
// <name>_b, and opens a session on it; cleanup removes it with the first.
Second func() (*Env, error)
Admin *sql.DB // server connection used to create and drop probe objects
Extra map[string]string
Err error
Notes []string
}
Env is the connection of one probe. A failed step records the first error; later steps do nothing, so a probe body reads as its list of steps.
func (*Env) Fails ¶
Fails runs a statement that must fail with the given error: a MySQL error number, a PostgreSQL SQLSTATE, or a substring of the SQLite message.
type Probe ¶
type Probe struct {
ID string
DB string
Fact string
Fixture ProbeFixture
Run func(e *Env)
}
Probe is one asserted fact. ID is stable and is cited by docs/spec/dialects.md.
type ProbeFixture ¶
type ProbeFixture string
ProbeFixture names an explicitly selected test server fixture for a probe.
const ( ProbeFixtureDefault ProbeFixture = "" ProbeFixtureMySQLPrivilege ProbeFixture = "mysql-privilege" )