cockroach: github.com/cockroachdb/cockroach/pkg/testutils/pgtest Index | Files

package pgtest

import "github.com/cockroachdb/cockroach/pkg/testutils/pgtest"

Index

Package Files

datadriven.go pgtest.go

func RunTest Uses

func RunTest(t *testing.T, path, addr, user string)

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.

func Walk Uses

func Walk(t *testing.T, path, addr, user string)

Walk walks path for datadriven files and calls RunTest on them.

type PGTest Uses

type PGTest struct {
    // contains filtered or unexported fields
}

PGTest can be used to send and receive arbitrary pgwire messages on Postgres-compatible servers.

func NewPGTest Uses

func NewPGTest(ctx context.Context, addr, user string) (*PGTest, error)

NewPGTest connects to a Postgres server at addr with username user.

func (*PGTest) Close Uses

func (p *PGTest) Close() error

Close sends a Terminate message and closes the connection.

func (*PGTest) Receive Uses

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 Uses

func (p *PGTest) Send(msg pgproto3.FrontendMessage) error

Send sends msg to the serrver.

func (*PGTest) Until Uses

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.

Package pgtest imports 10 packages (graph). Updated 2019-08-17. Refresh now. Tools for package owners.