testutils

package
v0.0.0-...-982e07a Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSLRequestOk = 'S'
	SSLRequestNo = 'N'
)

Valid responses on SSLRequest

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectDataRowsStep

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

CollectDataRowsStep used to receive and store rows from the database DataRow response

func NewCollectDataRowsStep

func NewCollectDataRowsStep(count int) *CollectDataRowsStep

NewCollectDataRowsStep creates step that collects <count> DataRow packet's values and export them

func (*CollectDataRowsStep) GetRows

func (step *CollectDataRowsStep) GetRows() []RowData

GetRows returns collected rows

func (*CollectDataRowsStep) Step

func (step *CollectDataRowsStep) Step(frontend *Frontend) error

Step receive and store DataRow packets count times

type Frontend

type Frontend struct {
	*pgproto3.Frontend
	// contains filtered or unexported fields
}

Frontend extends pgproto3.Frontend

func NewFrontend

func NewFrontend(connIn, connOut net.Conn) *Frontend

NewFrontend returns new Frontend

func (*Frontend) Close

func (f *Frontend) Close() error

Close sends Terminate packet and closes connections

func (*Frontend) ReadSSLResponse

func (f *Frontend) ReadSSLResponse() (byte, error)

ReadSSLResponse reads and returns response on SSLRequest

func (*Frontend) SwitchToTLS

func (f *Frontend) SwitchToTLS(ctx context.Context, tlsConfig *tls.Config) error

SwitchToTLS switch frontend's connections to the TLS. Expects that database responded 'S' on SSLRequest

type RowData

type RowData [][]byte

RowData represents row of DataRow

type Script

type Script struct {
	Steps []Step
}

Script store and run steps until gets error

func (*Script) Run

func (s *Script) Run(frontend *Frontend) error

Run runs all steps until error

func (*Script) Step

func (s *Script) Step(frontend *Frontend) error

Step whole script works as one step

type Step

type Step interface {
	Step(*Frontend) error
}

Step execute one step of flow

func ExpectAnyMessage

func ExpectAnyMessage(want pgproto3.BackendMessage) Step

ExpectAnyMessage creates step to receive one packet and compare only the type with "want"s type

func ExpectMessage

func ExpectMessage(want pgproto3.BackendMessage) Step

ExpectMessage creates step to receive one packet and verify that it deeply equals to "want" message

func NewAuthStep

func NewAuthStep(ctx context.Context, tlsConfig *tls.Config, database, username, password string) Step

NewAuthStep returns step to send Startup message and process authentication with password md5 authentication

func NewFlushStep

func NewFlushStep() Step

NewFlushStep returns step that flushes frontend's buffer and sends collected packets to the connection

func SendMessage

func SendMessage(msg pgproto3.FrontendMessage) Step

SendMessage sends message to the frontend's buffer but not flushes. It will be sent only on buffer overload or FlushStep

func WaitForStep

func WaitForStep(msg pgproto3.BackendMessage) Step

WaitForStep creates step that skips all messages from the frontend until gets message with msg's type

Jump to

Keyboard shortcuts

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