Documentation
¶
Overview ¶
Package dbtest provides test helpers for database stores.
Index ¶
- type QueryCounter
- func (qc *QueryCounter) Begin(ctx context.Context) (pgx.Tx, error)
- func (qc *QueryCounter) Count() int
- func (qc *QueryCounter) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
- func (qc *QueryCounter) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
- func (qc *QueryCounter) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
- func (qc *QueryCounter) Reset()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type QueryCounter ¶
type QueryCounter struct {
// contains filtered or unexported fields
}
QueryCounter wraps a store.DBTX and counts every query-level call (Exec, Query, QueryRow). Begin is counted once (for the BEGIN itself); calls on the returned transaction are also counted via a wrapped Tx.
func NewQueryCounter ¶
func NewQueryCounter(db store.DBTX) *QueryCounter
NewQueryCounter wraps the given DBTX with call counting.
func (*QueryCounter) Begin ¶
Begin delegates to the underlying DBTX and returns a counted transaction.
func (*QueryCounter) Count ¶
func (qc *QueryCounter) Count() int
Count returns the number of database calls observed so far.
func (*QueryCounter) Exec ¶
func (qc *QueryCounter) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Exec delegates to the underlying DBTX and increments the counter.
Click to show internal directories.
Click to hide internal directories.