Documentation ¶
Index ¶
- func RunTest(t *testing.T, path, addr, user string)
- func WalkWithNewServer(t *testing.T, path string, ...)
- func WalkWithRunningServer(t *testing.T, path, addr, user string)
- type PGTest
- func (p *PGTest) Close() error
- func (p *PGTest) Receive(keepErrMsg bool, typs ...pgproto3.BackendMessage) ([]pgproto3.BackendMessage, error)
- func (p *PGTest) Send(msg pgproto3.FrontendMessage) error
- func (p *PGTest) Until(keepErrMsg bool, typs ...pgproto3.BackendMessage) ([]pgproto3.BackendMessage, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunTest ¶
RunTest executes PGTest commands, connecting to the database specified by addr and user. Supported commands:
"send": Sends messages to a server. Takes a newline-delimited list of pgproto3.FrontendMessage types. Can fill in values by adding a space then a JSON object. No output.
"until": Receives all messages from a server until messages of the given types have been seen. Converts them to JSON one per line as output. Takes a newline-delimited list of pgproto3.BackendMessage types. An ignore option can be used to specify types to ignore. ErrorResponse messages are immediately returned as errors unless they are the expected type, in which case they will marshal to an empty ErrorResponse message since our error detail specifics differ from Postgres.
"receive": Like "until", but only output matching messages instead of all messages.
If the argument crdb_only is given and the server is non-crdb (e.g. posrgres), then the exchange is skipped. With noncrdb_only, the inverse happens.
func WalkWithNewServer ¶
func WalkWithNewServer( t *testing.T, path string, newServer func() (addr, user string, cleanup func()), )
WalkWithNewServer walks path for datadriven files and calls RunTest on them, but creates a new server for each test file.
func WalkWithRunningServer ¶
WalkWithRunningServer walks path for datadriven files and calls RunTest on them. It is used when an existing server is desired for each test.
Types ¶
type PGTest ¶
type PGTest struct {
// contains filtered or unexported fields
}
PGTest can be used to send and receive arbitrary pgwire messages on Postgres-compatible servers.
func (*PGTest) Receive ¶
func (p *PGTest) Receive( keepErrMsg bool, typs ...pgproto3.BackendMessage, ) ([]pgproto3.BackendMessage, error)
Receive reads messages until messages of the given types have been found in the specified order (with any number of messages in between). It returns matched messages.
func (*PGTest) Send ¶
func (p *PGTest) Send(msg pgproto3.FrontendMessage) error
Send sends msg to the serrver.
func (*PGTest) Until ¶
func (p *PGTest) Until( keepErrMsg bool, typs ...pgproto3.BackendMessage, ) ([]pgproto3.BackendMessage, error)
Until is like Receive except all messages are returned instead of only matched messages.