tests

package
v0.0.0-...-cab28d8 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFake = errors.New("fake error for tests")

ErrFake represents a fake error used in tests.

View Source
var ErrFakeDB = errors.New("fake database failure")

ErrFakeDB represents a fake database error.

Functions

This section is empty.

Types

type DBMock

type DBMock struct {
	mock.Mock
}

DBMock is a mock implementation of the DB interface.

func (*DBMock) Acquire

func (m *DBMock) Acquire(ctx context.Context) (*pgxpool.Conn, error)

Acquire implements the DB interface.

func (*DBMock) Begin

func (m *DBMock) Begin(ctx context.Context) (pgx.Tx, error)

Begin implements the DB interface.

func (*DBMock) Exec

func (m *DBMock) Exec(ctx context.Context, query string, params ...interface{}) (pgconn.CommandTag, error)

Exec implements the DB interface.

func (*DBMock) QueryRow

func (m *DBMock) QueryRow(ctx context.Context, query string, params ...interface{}) pgx.Row

QueryRow implements the DB interface.

type ErrReader

type ErrReader int

ErrReader represents a faulty reader implementation. It can be handy to simulate faulty requests bodies (ioutil.NopCloser(tests.ErrReader(0))).

func (ErrReader) Read

func (ErrReader) Read(p []byte) (n int, err error)

Read implements the io.Reader interface.

type HTTPClientMock

type HTTPClientMock struct {
	mock.Mock
}

HTTPClientMock is a mock HTTPClient implementation.

func (*HTTPClientMock) Do

func (m *HTTPClientMock) Do(req *http.Request) (*http.Response, error)

Do implements the HTTPClient interface.

type RowMock

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

RowMock is a mock implementation of the pgx.Row interface.

func (*RowMock) Scan

func (m *RowMock) Scan(dest ...interface{}) error

Scan implements pgx.Row interface.

type TXMock

type TXMock struct {
	mock.Mock
}

TXMock is a mock implementation of the pgx.Tx interface.

func (*TXMock) Begin

func (m *TXMock) Begin(ctx context.Context) (pgx.Tx, error)

Begin implements the pgx.Tx interface.

func (*TXMock) BeginFunc

func (m *TXMock) BeginFunc(ctx context.Context, f func(pgx.Tx) error) error

BeginFunc implements the pgx.Tx interface.

func (*TXMock) Commit

func (m *TXMock) Commit(ctx context.Context) error

Commit implements the pgx.Tx interface.

func (*TXMock) Conn

func (m *TXMock) Conn() *pgx.Conn

Conn implements the pgx.Tx interface.

func (*TXMock) CopyFrom

func (m *TXMock) CopyFrom(
	ctx context.Context,
	tableName pgx.Identifier,
	columnNames []string,
	rowSrc pgx.CopyFromSource,
) (int64, error)

CopyFrom implements the pgx.Tx interface.

func (*TXMock) Exec

func (m *TXMock) Exec(ctx context.Context, query string, params ...interface{}) (pgconn.CommandTag, error)

Exec implements the pgx.Tx interface.

func (*TXMock) LargeObjects

func (m *TXMock) LargeObjects() pgx.LargeObjects

LargeObjects implements the pgx.Tx interface.

func (*TXMock) Prepare

func (m *TXMock) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)

Prepare implements the pgx.Tx interface.

func (*TXMock) Query

func (m *TXMock) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

Query implements the pgx.Tx interface.

func (*TXMock) QueryFunc

func (m *TXMock) QueryFunc(
	ctx context.Context,
	sql string,
	args []interface{},
	scans []interface{},
	f func(pgx.QueryFuncRow) error,
) (pgconn.CommandTag, error)

QueryFunc implements the pgx.Tx interface.

func (*TXMock) QueryRow

func (m *TXMock) QueryRow(ctx context.Context, query string, params ...interface{}) pgx.Row

QueryRow implements the pgx.Tx interface.

func (*TXMock) Rollback

func (m *TXMock) Rollback(ctx context.Context) error

Rollback implements the pgx.Tx interface.

func (*TXMock) SendBatch

func (m *TXMock) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

SendBatch implements the pgx.Tx interface.

Jump to

Keyboard shortcuts

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