Documentation
¶
Overview ¶
Package postgrestest is a small fake PostgreSQL server for tests, in this package and in others. It speaks the simple query protocol only, so a test must use the driver's default query_mode (simple). It does not parse SQL: the test gives it a Handler that answers each SQL text.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
Column is one column of a Result. OID is the PostgreSQL type, such as 25 for text, 23 for int4 and 16 for bool. Use Text and Int for the usual ones.
type Handler ¶
Handler answers one query text. It returns one Result for each statement in the text. No result at all means an empty query.
type Result ¶
type Result struct {
Columns []Column
Rows [][]any
// Tag is the command tag, such as "SELECT 2" or "UPDATE 1".
Tag string
// ErrCode and ErrMessage, when set, make the statement fail. The statements
// after it in the same query are not run.
ErrCode string
ErrMessage string
}
Result is the answer to one statement. A cell is a string, or nil for NULL.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a running fake server.
func StartWithPassword ¶
StartWithPassword is Start, but a client must log in with this password.