databasemock

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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) Query

func (c *ConnectionMock) Query(ctx context.Context, sql string, args ...any) ([]map[string]any, error)

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) Close

func (p *PoolMock) Close()

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

func (p *PoolMock) IsPoolClosed() bool

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

func (p *PoolMock) WithCloseFunc(fn func()) *PoolMock

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

Jump to

Keyboard shortcuts

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