Documentation
¶
Overview ¶
Package pgxpoolmock is a generated GoMock package.
Package pgxpoolmock is a generated GoMock package.
Index ¶
- Variables
- func QueryContains(s string) gomock.Matcher
- type BatchResults
- type MockBatchResults
- type MockBatchResultsMockRecorder
- type MockPgxIface
- func (m *MockPgxIface) Begin(ctx context.Context) (pgx.Tx, error)
- func (m *MockPgxIface) BeginFunc(ctx context.Context, f func(pgx.Tx) error) error
- func (m *MockPgxIface) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
- func (m *MockPgxIface) BeginTxFunc(ctx context.Context, txOptions pgx.TxOptions, f func(pgx.Tx) error) error
- func (m *MockPgxIface) Close()
- func (m *MockPgxIface) Commit(ctx context.Context) error
- func (m *MockPgxIface) Conn() *pgx.Conn
- func (m *MockPgxIface) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnName []string, ...) (int64, error)
- func (m *MockPgxIface) EXPECT() *MockPgxIfaceMockRecorder
- func (m *MockPgxIface) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
- func (m *MockPgxIface) LargeObjects() pgx.LargeObjects
- func (m *MockPgxIface) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
- func (m *MockPgxIface) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (m *MockPgxIface) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (m *MockPgxIface) Rollback(ctx context.Context) error
- func (m *MockPgxIface) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
- type MockPgxIfaceMockRecorder
- func (mr *MockPgxIfaceMockRecorder) Begin(ctx interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) BeginFunc(ctx, f interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) BeginTx(ctx, txOptions interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) BeginTxFunc(ctx, txOptions, f interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) Close() *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) Commit(ctx interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) Conn() *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) CopyFrom(ctx, tableName, columnName, rowSvc interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) Exec(ctx, sql interface{}, arguments ...interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) LargeObjects() *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) Prepare(ctx, name, sql interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) Query(ctx, sql interface{}, args ...interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) QueryRow(ctx, sql interface{}, args ...interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) Rollback(ctx interface{}) *gomock.Call
- func (mr *MockPgxIfaceMockRecorder) SendBatch(ctx, b interface{}) *gomock.Call
- type PgxIface
- type PgxPool
- type QueryContainsMatcher
- type Row
- type Rows
Constants ¶
This section is empty.
Variables ¶
var ( // Use the error to signify the end of a batch result. ErrEndBatchResult = fmt.Errorf("batch already closed") ErrNoBatchResult = fmt.Errorf("no result") )
var CSVColumnParser = func(s string) interface{} { switch { case strings.ToLower(s) == "null": return nil } return s }
CSVColumnParser is a function which converts trimmed csv column string to a []byte representation. Currently transforms NULL to nil
Functions ¶
func QueryContains ¶
Types ¶
type BatchResults ¶
type BatchResults interface { Exec() (pgconn.CommandTag, error) Query() (pgx.Rows, error) QueryRow() pgx.Row Close() error }
BatchResults is the same interface as pgx.BatchResults, placed here for mocking. https://github.com/jackc/pgx/blob/dc0ad04ff58f72f4819289f54745a36124cdbec3/batch.go#L35-L52
type MockBatchResults ¶
type MockBatchResults struct {
// contains filtered or unexported fields
}
MockBatchResults is a mock of BatchResults interface.
func NewMockBatchResults ¶
func NewMockBatchResults(ctrl *gomock.Controller) *MockBatchResults
NewMockBatchResults creates a new mock instance.
func (*MockBatchResults) EXPECT ¶
func (m *MockBatchResults) EXPECT() *MockBatchResultsMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockBatchResults) Exec ¶
func (m *MockBatchResults) Exec() (pgconn.CommandTag, error)
Exec mocks base method.
func (*MockBatchResults) Query ¶
func (m *MockBatchResults) Query() (pgx.Rows, error)
Query mocks base method.
func (*MockBatchResults) QueryRow ¶
func (m *MockBatchResults) QueryRow() pgx.Row
QueryRow mocks base method.
type MockBatchResultsMockRecorder ¶
type MockBatchResultsMockRecorder struct {
// contains filtered or unexported fields
}
MockBatchResultsMockRecorder is the mock recorder for MockBatchResults.
func (*MockBatchResultsMockRecorder) Close ¶
func (mr *MockBatchResultsMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockBatchResultsMockRecorder) Exec ¶
func (mr *MockBatchResultsMockRecorder) Exec() *gomock.Call
Exec indicates an expected call of Exec.
func (*MockBatchResultsMockRecorder) Query ¶
func (mr *MockBatchResultsMockRecorder) Query() *gomock.Call
Query indicates an expected call of Query.
func (*MockBatchResultsMockRecorder) QueryRow ¶
func (mr *MockBatchResultsMockRecorder) QueryRow() *gomock.Call
QueryRow indicates an expected call of QueryRow.
type MockPgxIface ¶
type MockPgxIface struct {
// contains filtered or unexported fields
}
MockPgxIface is a mock of PgxIface interface.
func NewMockPgxIface ¶
func NewMockPgxIface(ctrl *gomock.Controller) *MockPgxIface
NewMockPgxIface creates a new mock instance.
func (*MockPgxIface) BeginTxFunc ¶
func (m *MockPgxIface) BeginTxFunc(ctx context.Context, txOptions pgx.TxOptions, f func(pgx.Tx) error) error
BeginTxFunc mocks base method.
func (*MockPgxIface) Commit ¶
func (m *MockPgxIface) Commit(ctx context.Context) error
Commit mocks base method.
func (*MockPgxIface) CopyFrom ¶
func (m *MockPgxIface) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnName []string, rowSvc pgx.CopyFromSource) (int64, error)
CopyFrom mocks base method.
func (*MockPgxIface) EXPECT ¶
func (m *MockPgxIface) EXPECT() *MockPgxIfaceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPgxIface) Exec ¶
func (m *MockPgxIface) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
Exec mocks base method.
func (*MockPgxIface) LargeObjects ¶
func (m *MockPgxIface) LargeObjects() pgx.LargeObjects
LargeObjects mocks base method.
func (*MockPgxIface) Prepare ¶
func (m *MockPgxIface) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
Prepare mocks base method.
func (*MockPgxIface) Query ¶
func (m *MockPgxIface) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
Query mocks base method.
func (*MockPgxIface) Rollback ¶
func (m *MockPgxIface) Rollback(ctx context.Context) error
Rollback mocks base method.
func (*MockPgxIface) SendBatch ¶
func (m *MockPgxIface) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
SendBatch mocks base method.
type MockPgxIfaceMockRecorder ¶
type MockPgxIfaceMockRecorder struct {
// contains filtered or unexported fields
}
MockPgxIfaceMockRecorder is the mock recorder for MockPgxIface.
func (*MockPgxIfaceMockRecorder) Begin ¶
func (mr *MockPgxIfaceMockRecorder) Begin(ctx interface{}) *gomock.Call
Begin indicates an expected call of Begin.
func (*MockPgxIfaceMockRecorder) BeginFunc ¶
func (mr *MockPgxIfaceMockRecorder) BeginFunc(ctx, f interface{}) *gomock.Call
BeginFunc indicates an expected call of BeginFunc.
func (*MockPgxIfaceMockRecorder) BeginTx ¶
func (mr *MockPgxIfaceMockRecorder) BeginTx(ctx, txOptions interface{}) *gomock.Call
BeginTx indicates an expected call of BeginTx.
func (*MockPgxIfaceMockRecorder) BeginTxFunc ¶
func (mr *MockPgxIfaceMockRecorder) BeginTxFunc(ctx, txOptions, f interface{}) *gomock.Call
BeginTxFunc indicates an expected call of BeginTxFunc.
func (*MockPgxIfaceMockRecorder) Close ¶
func (mr *MockPgxIfaceMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockPgxIfaceMockRecorder) Commit ¶
func (mr *MockPgxIfaceMockRecorder) Commit(ctx interface{}) *gomock.Call
Commit indicates an expected call of Commit.
func (*MockPgxIfaceMockRecorder) Conn ¶
func (mr *MockPgxIfaceMockRecorder) Conn() *gomock.Call
Conn indicates an expected call of Conn.
func (*MockPgxIfaceMockRecorder) CopyFrom ¶
func (mr *MockPgxIfaceMockRecorder) CopyFrom(ctx, tableName, columnName, rowSvc interface{}) *gomock.Call
CopyFrom indicates an expected call of CopyFrom.
func (*MockPgxIfaceMockRecorder) Exec ¶
func (mr *MockPgxIfaceMockRecorder) Exec(ctx, sql interface{}, arguments ...interface{}) *gomock.Call
Exec indicates an expected call of Exec.
func (*MockPgxIfaceMockRecorder) LargeObjects ¶
func (mr *MockPgxIfaceMockRecorder) LargeObjects() *gomock.Call
LargeObjects indicates an expected call of LargeObjects.
func (*MockPgxIfaceMockRecorder) Prepare ¶
func (mr *MockPgxIfaceMockRecorder) Prepare(ctx, name, sql interface{}) *gomock.Call
Prepare indicates an expected call of Prepare.
func (*MockPgxIfaceMockRecorder) Query ¶
func (mr *MockPgxIfaceMockRecorder) Query(ctx, sql interface{}, args ...interface{}) *gomock.Call
Query indicates an expected call of Query.
func (*MockPgxIfaceMockRecorder) QueryRow ¶
func (mr *MockPgxIfaceMockRecorder) QueryRow(ctx, sql interface{}, args ...interface{}) *gomock.Call
QueryRow indicates an expected call of QueryRow.
func (*MockPgxIfaceMockRecorder) Rollback ¶
func (mr *MockPgxIfaceMockRecorder) Rollback(ctx interface{}) *gomock.Call
Rollback indicates an expected call of Rollback.
func (*MockPgxIfaceMockRecorder) SendBatch ¶
func (mr *MockPgxIfaceMockRecorder) SendBatch(ctx, b interface{}) *gomock.Call
SendBatch indicates an expected call of SendBatch.
type PgxIface ¶
type PgxIface interface { // pgx.Tx Commit(ctx context.Context) error Rollback(ctx context.Context) error CopyFrom(ctx context.Context, tableName pgx.Identifier, columnName []string, rowSvc pgx.CopyFromSource) (int64, error) LargeObjects() pgx.LargeObjects Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error) Conn() *pgx.Conn // pgx.PgxPool Close() Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults Begin(ctx context.Context) (pgx.Tx, error) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) BeginFunc(ctx context.Context, f func(pgx.Tx) error) error BeginTxFunc(ctx context.Context, txOptions pgx.TxOptions, f func(pgx.Tx) error) error }
Implements pgxpool.PgxPool and pgx.Tx
type PgxPool ¶
type PgxPool interface { Close() Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults Begin(ctx context.Context) (pgx.Tx, error) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) }
type QueryContainsMatcher ¶
type QueryContainsMatcher struct {
// contains filtered or unexported fields
}
QueryContainsMatcher implements the gomock matcher interface (https://pkg.go.dev/github.com/golang/mock/gomock#Matcher) to match a string (SQL query) that contains the given string. This is useful for passing into pgxpoolmock.MockPgxIface as the SQL query string argument since SQLC generated code will contain the associated function name as well.
Usage: pgxMock.EXPECT().QueryRow(gomock.Any(), QueryContains("GetSomething")).Return(NewRow(1, "foo"))
func (*QueryContainsMatcher) Matches ¶
func (m *QueryContainsMatcher) Matches(x interface{}) bool
func (*QueryContainsMatcher) String ¶
func (m *QueryContainsMatcher) String() string
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row implements the pgx.Row interface and can be passed into pgxpoolmock.PgxPoolMock.QueryRow as the expected returned row.
Usage: pgxMock.EXPECT().QueryRow(gomock.Any(), HasString("GetEntityByID")).Return(NewRow(1, "foo"))
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows is a mocked collection of rows to return for Query result
func NewRows ¶
NewMockRows allows Rows to be created from a sql interface{} slice or from the CSV string and to be used as sql driver.Rows. Use Sqlmock.NewRows instead if using a custom converter
func NewRowsWithColumnDefinition ¶
func NewRowsWithColumnDefinition(columns ...pgconn.FieldDescription) *Rows
NewRowsWithColumnDefinition return rows with columns metadata
func (*Rows) AddRow ¶
AddRow composed from database interface{} slice return the same instance to perform subsequent actions. Note that the number of values must match the number of columns
func (*Rows) CloseError ¶
CloseError allows to set an error which will be returned by rows.Close function.
The close error will be triggered only in cases when rows.Next() EOF was not yet reached, that is a default sql library behavior
func (*Rows) FromCSVString ¶
FromCSVString build rows from csv string. return the same instance to perform subsequent actions. Note that the number of values must match the number of columns