Documentation
¶
Index ¶
- type ConnectionMock
- func (c *ConnectionMock) Close()
- func (c *ConnectionMock) IsConnectionClosed() bool
- func (c *ConnectionMock) Query(ctx context.Context, sql string, args ...any) ([]map[string]any, error)
- func (c *ConnectionMock) WithCloseFunc(fn func()) *ConnectionMock
- func (c *ConnectionMock) WithQueryFunc(...) *ConnectionMock
- type PoolMock
- func (p *PoolMock) Close()
- func (p *PoolMock) GetConnection(params database.PoolParams) (database.Connection, error)
- func (p *PoolMock) GetConnectionCallCount(params database.PoolParams) int
- func (p *PoolMock) IsPoolClosed() bool
- func (p *PoolMock) RegisterConnection(params database.PoolParams, conn database.Connection)
- func (p *PoolMock) WithCloseFunc(fn func()) *PoolMock
- func (p *PoolMock) WithGetConnectionFunc(fn func(params database.PoolParams) (database.Connection, error)) *PoolMock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionMock ¶
type ConnectionMock struct { QueryFunc func(ctx context.Context, sql string, args ...any) ([]map[string]any, error) CloseFunc func() CloseCount int IsClosed *atomic.Bool }
func NewConnectionMock ¶
func NewConnectionMock() *ConnectionMock
func (*ConnectionMock) Close ¶
func (c *ConnectionMock) Close()
func (*ConnectionMock) IsConnectionClosed ¶
func (c *ConnectionMock) IsConnectionClosed() bool
IsConnectionClosed returns the status of the connection
func (*ConnectionMock) WithCloseFunc ¶
func (c *ConnectionMock) WithCloseFunc(fn func()) *ConnectionMock
WithCloseFunc allows setting a custom close function for testing
func (*ConnectionMock) WithQueryFunc ¶
func (c *ConnectionMock) WithQueryFunc(fn func(ctx context.Context, sql string, args ...any) ([]map[string]any, error)) *ConnectionMock
WithQueryFunc allows setting a custom query function for testing
type PoolMock ¶
type PoolMock struct { GetConnectionFunc func(params database.PoolParams) (database.Connection, error) CloseFunc func() IsClosed *atomic.Bool CloseCount int // contains filtered or unexported fields }
func NewPoolMock ¶
func NewPoolMock() *PoolMock
func (*PoolMock) GetConnection ¶
func (p *PoolMock) GetConnection(params database.PoolParams) (database.Connection, error)
func (*PoolMock) GetConnectionCallCount ¶
func (p *PoolMock) GetConnectionCallCount(params database.PoolParams) int
GetConnectionCallCount returns the number of times GetConnection was called with the given parameters
func (*PoolMock) IsPoolClosed ¶
IsPoolClosed returns the status of the pool
func (*PoolMock) RegisterConnection ¶
func (p *PoolMock) RegisterConnection(params database.PoolParams, conn database.Connection)
RegisterConnection allows registering a specific connection for specific parameters
func (*PoolMock) WithCloseFunc ¶
WithCloseFunc allows setting a custom close function for testing
func (*PoolMock) WithGetConnectionFunc ¶
func (p *PoolMock) WithGetConnectionFunc(fn func(params database.PoolParams) (database.Connection, error)) *PoolMock
WithGetConnectionFunc allows setting a custom GetConnection function for testing
Click to show internal directories.
Click to hide internal directories.