pgtest

package
v2.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeMem

func ServeMem(server *pg.Server) (ConnectFunc, ShutdownFunc, error)

ServeMem serves postgres on in-memory connections. TLS does not work here, as it relies on the OS to buffer and discard data.

func SetupTLS

func SetupTLS(server *pg.Server) error

SetupTLS generates a TLS certificate and installs it into the server. TODO: have the client properly trust this (generate a CA to install instead of using self-signed).

Types

type ConnectFunc

type ConnectFunc func() (net.Conn, error)

ConnectFunc is a function to connect to a server.

type HandlerFunc

type HandlerFunc func(context.Context, pg.QueryResultWriter, pg.Query) error

HandlerFunc implements a postgres query handler with a function.

func (HandlerFunc) HandleQuery

func (h HandlerFunc) HandleQuery(ctx context.Context, w pg.QueryResultWriter, q pg.Query) error

HandleQuery calls the user's query handler function.

type ResultSet

type ResultSet struct {
	Columns   []pg.ColumnInfo
	Data      [][]string
	ResultTag string
}

ResultSet is a QueryResultWriter that accumulates results in a slice.

func (ResultSet) String added in v2.3.0

func (s ResultSet) String() string

func (*ResultSet) Tag

func (rs *ResultSet) Tag(tag string)

Tag applies a tag to the result set.

func (*ResultSet) WriteHeader

func (rs *ResultSet) WriteHeader(cols ...pg.ColumnInfo) error

WriteHeader writes headers to the result set.

func (*ResultSet) WriteRowText

func (rs *ResultSet) WriteRowText(vals ...string) error

WriteRowText writes a row to the result set.

type ShutdownFunc

type ShutdownFunc func() error

ShutdownFunc is a function to use to shut down a test fixture. This function will send a shutdown signal and then wait for completion.

func ServeTCP

func ServeTCP(addr string, server *pg.Server) (net.Addr, ShutdownFunc, error)

ServeTCP creates a TCP listener and serves postgres wire protocol on it.

func ServeTLS

func ServeTLS(addr string, server *pg.Server) (net.Addr, ShutdownFunc, error)

ServeTLS sets up TLS on the server and invokes ServeTCP.

func (ShutdownFunc) Finish

func (f ShutdownFunc) Finish(tb testing.TB, name string)

Finish invokes the shutdown function and fails the test if an error occurs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL