conn

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package conn is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionOption

type ConnectionOption func(*ConnectionOptionData)

ConnectionOption options for Connection.

func WithLogQueries

func WithLogQueries() ConnectionOption

WithLogQueries enables query logging at the specific GetDB call level.

type ConnectionOptionData

type ConnectionOptionData struct {
	LogQueries bool
}

ConnectionOptionData option data for Connection.

type ErrRow

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

ErrRow wrapper around pgx.Row that always returns an error.

func NewErrRow

func NewErrRow(err error) *ErrRow

NewErrRow creates an ErrRow.

func (ErrRow) Scan

func (e ErrRow) Scan(_ ...any) error

Scan returns an error.

type ErrorWrapper

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

ErrorWrapper implements the IConnection interface with error return.

func NewDatabaseErrorWrapper

func NewDatabaseErrorWrapper(err error) *ErrorWrapper

NewDatabaseErrorWrapper creates a databaseErrorWrapper.

func (*ErrorWrapper) CopyFrom

func (i *ErrorWrapper) CopyFrom(_ context.Context, _ pgx.Identifier,
	_ []string, _ pgx.CopyFromSource,
) (n int64, err error)

CopyFrom returns an error.

func (*ErrorWrapper) Exec

func (i *ErrorWrapper) Exec(_ context.Context, _ string, _ ...any) (tag pgconn.CommandTag, err error)

Exec returns an error.

func (*ErrorWrapper) InTransaction

func (i *ErrorWrapper) InTransaction() bool

InTransaction always returns false.

func (*ErrorWrapper) LargeObjects

func (i *ErrorWrapper) LargeObjects() pgx.LargeObjects

LargeObjects panics because it needs to return pgx.LargeObjects which contains private fields and has no constructor.

func (*ErrorWrapper) Query

func (i *ErrorWrapper) Query(_ context.Context, _ string, _ ...any) (rows pgx.Rows, err error)

Query returns an error.

func (*ErrorWrapper) QueryRow

func (i *ErrorWrapper) QueryRow(_ context.Context, _ string, _ ...any) (row pgx.Row)

QueryRow returns an error.

func (*ErrorWrapper) SendBatch

func (i *ErrorWrapper) SendBatch(_ context.Context, _ *pgx.Batch) (res pgx.BatchResults)

SendBatch returns an error.

func (*ErrorWrapper) TransactionOptions

func (i *ErrorWrapper) TransactionOptions() txmgr.Options

TransactionOptions always returns an empty object.

func (*ErrorWrapper) WithoutTransaction

func (i *ErrorWrapper) WithoutTransaction(ctx context.Context) context.Context

WithoutTransaction returns a context without transaction.

type IConnection

type IConnection interface {
	// Exec executes a query without returning data
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	// Query executes a query and returns the result
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	// QueryRow gets a connection and executes a query that should return no more than one row.
	// Errors are deferred until the pgx.Row.Scan method is called.
	// If the query selects no rows, pgx.Row.Scan will return pgx.ErrNoRows.
	// Otherwise, pgx.Row.Scan scans the first selected row and discards the rest.
	// The obtained connection is returned to the pool when the pgx.Row.Scan method is called.
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	// SendBatch sends a batch of queries for execution, combining all queries into a single batch
	SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
	// CopyFrom implements bulk data insertion into a table
	CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)

	// LargeObjects supports working with large objects and is only available
	// in a transaction (this is a PostgreSQL limitation).
	// Will panic if used outside a transaction.
	LargeObjects() pgx.LargeObjects

	// InTransaction returns true if a transaction has started.
	InTransaction() bool
	// TransactionOptions returns transaction options. If no transaction has started, returns false.
	TransactionOptions() txmgr.Options
	// WithoutTransaction returns a context without a transaction.
	WithoutTransaction(ctx context.Context) context.Context
}

IConnection includes methods from pgxpool.Pool, pgx.Conn and pgx.Tx + methods for checking transaction state.

type MockIConnection

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

MockIConnection is a mock of IConnection interface.

func NewMockIConnection

func NewMockIConnection(ctrl *gomock.Controller) *MockIConnection

NewMockIConnection creates a new mock instance.

func (*MockIConnection) CopyFrom

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

CopyFrom mocks base method.

func (*MockIConnection) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIConnection) Exec

func (m *MockIConnection) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)

Exec mocks base method.

func (*MockIConnection) InTransaction

func (m *MockIConnection) InTransaction() bool

InTransaction mocks base method.

func (*MockIConnection) LargeObjects

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

LargeObjects mocks base method.

func (*MockIConnection) Query

func (m *MockIConnection) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)

Query mocks base method.

func (*MockIConnection) QueryRow

func (m *MockIConnection) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row

QueryRow mocks base method.

func (*MockIConnection) SendBatch

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

SendBatch mocks base method.

func (*MockIConnection) TransactionOptions

func (m *MockIConnection) TransactionOptions() txmgr.Options

TransactionOptions mocks base method.

func (*MockIConnection) WithoutTransaction

func (m *MockIConnection) WithoutTransaction(ctx context.Context) context.Context

WithoutTransaction mocks base method.

type MockIConnectionMockRecorder

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

MockIConnectionMockRecorder is the mock recorder for MockIConnection.

func (*MockIConnectionMockRecorder) CopyFrom

func (mr *MockIConnectionMockRecorder) CopyFrom(ctx, tableName, columnNames, rowSrc any) *gomock.Call

CopyFrom indicates an expected call of CopyFrom.

func (*MockIConnectionMockRecorder) Exec

func (mr *MockIConnectionMockRecorder) Exec(ctx, sql any, arguments ...any) *gomock.Call

Exec indicates an expected call of Exec.

func (*MockIConnectionMockRecorder) InTransaction

func (mr *MockIConnectionMockRecorder) InTransaction() *gomock.Call

InTransaction indicates an expected call of InTransaction.

func (*MockIConnectionMockRecorder) LargeObjects

func (mr *MockIConnectionMockRecorder) LargeObjects() *gomock.Call

LargeObjects indicates an expected call of LargeObjects.

func (*MockIConnectionMockRecorder) Query

func (mr *MockIConnectionMockRecorder) Query(ctx, sql any, args ...any) *gomock.Call

Query indicates an expected call of Query.

func (*MockIConnectionMockRecorder) QueryRow

func (mr *MockIConnectionMockRecorder) QueryRow(ctx, sql any, args ...any) *gomock.Call

QueryRow indicates an expected call of QueryRow.

func (*MockIConnectionMockRecorder) SendBatch

func (mr *MockIConnectionMockRecorder) SendBatch(ctx, b any) *gomock.Call

SendBatch indicates an expected call of SendBatch.

func (*MockIConnectionMockRecorder) TransactionOptions

func (mr *MockIConnectionMockRecorder) TransactionOptions() *gomock.Call

TransactionOptions indicates an expected call of TransactionOptions.

func (*MockIConnectionMockRecorder) WithoutTransaction

func (mr *MockIConnectionMockRecorder) WithoutTransaction(ctx any) *gomock.Call

WithoutTransaction indicates an expected call of WithoutTransaction.

type MockIStartStopConnector

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

MockIStartStopConnector is a mock of IStartStopConnector interface.

func NewMockIStartStopConnector

func NewMockIStartStopConnector(ctrl *gomock.Controller) *MockIStartStopConnector

NewMockIStartStopConnector creates a new mock instance.

func (*MockIStartStopConnector) Connection

Connection mocks base method.

func (*MockIStartStopConnector) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIStartStopConnector) Start

Start mocks base method.

func (*MockIStartStopConnector) Stop

Stop mocks base method.

type MockIStartStopConnectorMockRecorder

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

MockIStartStopConnectorMockRecorder is the mock recorder for MockIStartStopConnector.

func (*MockIStartStopConnectorMockRecorder) Connection

func (mr *MockIStartStopConnectorMockRecorder) Connection(ctx any, opt ...any) *gomock.Call

Connection indicates an expected call of Connection.

func (*MockIStartStopConnectorMockRecorder) Start

Start indicates an expected call of Start.

func (*MockIStartStopConnectorMockRecorder) Stop

Stop indicates an expected call of Stop.

Jump to

Keyboard shortcuts

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