Documentation
¶
Index ¶
- type PGXPoolMock
- func (mock *PGXPoolMock) Begin(ctx context.Context) (v4.Tx, error)
- func (mock *PGXPoolMock) BeginCalls() []struct{ ... }
- func (mock *PGXPoolMock) Close()
- func (mock *PGXPoolMock) CloseCalls() []struct{}
- func (mock *PGXPoolMock) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
- func (mock *PGXPoolMock) ExecCalls() []struct{ ... }
- func (mock *PGXPoolMock) Ping(ctx context.Context) error
- func (mock *PGXPoolMock) PingCalls() []struct{ ... }
- func (mock *PGXPoolMock) Query(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error)
- func (mock *PGXPoolMock) QueryCalls() []struct{ ... }
- func (mock *PGXPoolMock) QueryRow(ctx context.Context, sql string, args ...interface{}) v4.Row
- func (mock *PGXPoolMock) QueryRowCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PGXPoolMock ¶
type PGXPoolMock struct {
// BeginFunc mocks the Begin method.
BeginFunc func(ctx context.Context) (v4.Tx, error)
// CloseFunc mocks the Close method.
CloseFunc func()
// ExecFunc mocks the Exec method.
ExecFunc func(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
// PingFunc mocks the Ping method.
PingFunc func(ctx context.Context) error
// QueryFunc mocks the Query method.
QueryFunc func(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error)
// QueryRowFunc mocks the QueryRow method.
QueryRowFunc func(ctx context.Context, sql string, args ...interface{}) v4.Row
// contains filtered or unexported fields
}
PGXPoolMock is a mock implementation of pgx.PGXPool.
func TestSomethingThatUsesPGXPool(t *testing.T) {
// make and configure a mocked pgx.PGXPool
mockedPGXPool := &PGXPoolMock{
BeginFunc: func(ctx context.Context) (v4.Tx, error) {
panic("mock out the Begin method")
},
CloseFunc: func() {
panic("mock out the Close method")
},
ExecFunc: func(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) {
panic("mock out the Exec method")
},
PingFunc: func(ctx context.Context) error {
panic("mock out the Ping method")
},
QueryFunc: func(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error) {
panic("mock out the Query method")
},
QueryRowFunc: func(ctx context.Context, sql string, args ...interface{}) v4.Row {
panic("mock out the QueryRow method")
},
}
// use mockedPGXPool in code that requires pgx.PGXPool
// and then make assertions.
}
func (*PGXPoolMock) BeginCalls ¶
func (mock *PGXPoolMock) BeginCalls() []struct { Ctx context.Context }
BeginCalls gets all the calls that were made to Begin. Check the length with:
len(mockedPGXPool.BeginCalls())
func (*PGXPoolMock) CloseCalls ¶
func (mock *PGXPoolMock) CloseCalls() []struct { }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedPGXPool.CloseCalls())
func (*PGXPoolMock) Exec ¶ added in v0.9.0
func (mock *PGXPoolMock) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
Exec calls ExecFunc.
func (*PGXPoolMock) ExecCalls ¶ added in v0.9.0
func (mock *PGXPoolMock) ExecCalls() []struct { Ctx context.Context SQL string Arguments []interface{} }
ExecCalls gets all the calls that were made to Exec. Check the length with:
len(mockedPGXPool.ExecCalls())
func (*PGXPoolMock) Ping ¶
func (mock *PGXPoolMock) Ping(ctx context.Context) error
Ping calls PingFunc.
func (*PGXPoolMock) PingCalls ¶
func (mock *PGXPoolMock) PingCalls() []struct { Ctx context.Context }
PingCalls gets all the calls that were made to Ping. Check the length with:
len(mockedPGXPool.PingCalls())
func (*PGXPoolMock) Query ¶
func (mock *PGXPoolMock) Query(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error)
Query calls QueryFunc.
func (*PGXPoolMock) QueryCalls ¶
func (mock *PGXPoolMock) QueryCalls() []struct { Ctx context.Context SQL string Args []interface{} }
QueryCalls gets all the calls that were made to Query. Check the length with:
len(mockedPGXPool.QueryCalls())
func (*PGXPoolMock) QueryRowCalls ¶
func (mock *PGXPoolMock) QueryRowCalls() []struct { Ctx context.Context SQL string Args []interface{} }
QueryRowCalls gets all the calls that were made to QueryRow. Check the length with:
len(mockedPGXPool.QueryRowCalls())
Click to show internal directories.
Click to hide internal directories.