mock

package
v0.0.0-...-d57b50c Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*Writer
	*Reader
	// contains filtered or unexported fields
}

func NewClient

func NewClient(t *testing.T, conn net.Conn) *Client

func (*Client) Authenticate

func (client *Client) Authenticate(t *testing.T)

Authenticate performs a simple authentication using the PostgreSQL wire protocol. The method fails whenever an unexpected message server message type/state has been returned of the connection has not been authenticated.

func (*Client) Close

func (client *Client) Close(t *testing.T)

func (*Client) Error

func (client *Client) Error(t *testing.T)

func (*Client) Handshake

func (client *Client) Handshake(t *testing.T)

Handshake performs a simple handshake over the underlaying connection. A handshake consists out of introducing/publishing the client version and connection preferences and the writing of (metadata) parameters identifying the given client.

func (*Client) ReadyForQuery

func (client *Client) ReadyForQuery(t *testing.T)

ReadyForQuery awaits till the underlaying network connection returns a ready for query message. This message indicates that the server is ready to accept a new typed message to execute a action.

type Reader

type Reader struct {
	*buffer.Reader
}

Reader represents a low level PostgreSQL client reader allowing a user to read messages through the PostgreSQL wire protocol. This implementation is mainly used for mocking/testing purposes.

func NewReader

func NewReader(t *testing.T, reader io.Reader) *Reader

NewReader constructs a new PostgreSQL wire protocol reader using the default buffer size.

func (*Reader) ReadTypedMsg

func (buffer *Reader) ReadTypedMsg() (types.ServerMessage, int, error)

ReadTypedMsg reads a message from the provided reader, returning its type code and body. It returns the message type, number of bytes read, and an error if there was one.

type Writer

type Writer struct {
	*buffer.Writer
}

Writer represents a low level PostgreSQL client writer allowing a user to write messages using the PostgreSQL wire protocol. This implementation is mainly used for mocking/testing purposes.

func NewWriter

func NewWriter(t *testing.T, writer io.Writer) *Writer

NewWriter constructs a new PostgreSQL wire protocol writer.

func (*Writer) Start

func (buffer *Writer) Start(t types.ClientMessage)

Start resets the buffer writer and starts a new message with the given message type. The message type (byte) and reserved message length bytes (int32) are written to the underlaying bytes buffer.

Jump to

Keyboard shortcuts

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