Documentation
¶
Index ¶
- Variables
- func NewResult(command string, rowsAffected int64) pgconn.CommandTag
- type AcquireAllIdleExpectation
- type AcquireExpectation
- type AcquireFuncExpectation
- type BeginExpectation
- type BeginTxExpectation
- type CloseExpectation
- type CommitExpectation
- type CopyFromExpectation
- func (e *CopyFromExpectation) String() string
- func (e *CopyFromExpectation) WillReturnError(err error)
- func (e *CopyFromExpectation) WillReturnResult(rowsAffected int64)
- func (e *CopyFromExpectation) WithArgs(args ...any)
- func (e *CopyFromExpectation) WithColumns(columns []string) *CopyFromExpectation
- type DeallocateAllExpectation
- type DeallocateExpectation
- type ExecExpectation
- type PGXMock
- func (m *PGXMock) AllExpectationsMet() error
- func (m *PGXMock) Begin(ctx context.Context) (pgx.Tx, error)
- func (m *PGXMock) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
- func (m *PGXMock) Close(ctx context.Context) error
- func (m *PGXMock) Commit(ctx context.Context) error
- func (m *PGXMock) Config() *pgx.ConnConfig
- func (m *PGXMock) Conn() *pgx.Conn
- func (m *PGXMock) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (m *PGXMock) Deallocate(ctx context.Context, name string) error
- func (m *PGXMock) DeallocateAll(ctx context.Context) error
- func (m *PGXMock) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
- func (m *PGXMock) ExpectBegin() *BeginExpectation
- func (m *PGXMock) ExpectBeginTx() *BeginTxExpectation
- func (m *PGXMock) ExpectClose() *CloseExpectation
- func (m *PGXMock) ExpectCommit() *CommitExpectation
- func (m *PGXMock) ExpectCopyFrom(tableName pgx.Identifier) *CopyFromExpectation
- func (m *PGXMock) ExpectDeallocate(name string) *DeallocateExpectation
- func (m *PGXMock) ExpectDeallocateAll() *DeallocateAllExpectation
- func (m *PGXMock) ExpectExec(query string) *ExecExpectation
- func (m *PGXMock) ExpectPing() *PingExpectation
- func (m *PGXMock) ExpectPrepare(name, sql string) *PrepareExpectation
- func (m *PGXMock) ExpectQuery(query string) *QueryExpectation
- func (m *PGXMock) ExpectQueryRow(query string) *QueryRowExpectation
- func (m *PGXMock) ExpectRollback() *RollbackExpectation
- func (m *PGXMock) LargeObjects() pgx.LargeObjects
- func (m *PGXMock) PgConn() *pgconn.PgConn
- func (m *PGXMock) Ping(ctx context.Context) error
- func (m *PGXMock) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
- func (m *PGXMock) Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
- func (m *PGXMock) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- func (m *PGXMock) Rollback(ctx context.Context) error
- func (m *PGXMock) SendBatch(ctx context.Context, batch *pgx.Batch) pgx.BatchResults
- type PGXPoolMock
- func (m *PGXPoolMock) Acquire(ctx context.Context) (*pgxpool.Conn, error)
- func (m *PGXPoolMock) AcquireAllIdle(ctx context.Context) []*pgxpool.Conn
- func (m *PGXPoolMock) AcquireFunc(ctx context.Context, fn func(*pgxpool.Conn) error) error
- func (m *PGXPoolMock) AllExpectationsMet() error
- func (m *PGXPoolMock) Begin(ctx context.Context) (pgx.Tx, error)
- func (m *PGXPoolMock) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
- func (m *PGXPoolMock) Close()
- func (m *PGXPoolMock) Commit(ctx context.Context) error
- func (m *PGXPoolMock) Config() *pgxpool.Config
- func (m *PGXPoolMock) Conn() *pgx.Conn
- func (m *PGXPoolMock) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (m *PGXPoolMock) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
- func (m *PGXPoolMock) ExpectAcquire() *AcquireExpectation
- func (m *PGXPoolMock) ExpectAcquireAllIdle() *AcquireAllIdleExpectation
- func (m *PGXPoolMock) ExpectAcquireFunc() *AcquireFuncExpectation
- func (m *PGXPoolMock) ExpectBegin() *BeginExpectation
- func (m *PGXPoolMock) ExpectBeginTx() *BeginTxExpectation
- func (m *PGXPoolMock) ExpectClose() *CloseExpectation
- func (m *PGXPoolMock) ExpectCommit() *CommitExpectation
- func (m *PGXPoolMock) ExpectCopyFrom(tableName pgx.Identifier) *PoolCopyFromExpectation
- func (m *PGXPoolMock) ExpectExec(query string) *ExecExpectation
- func (m *PGXPoolMock) ExpectPing() *PingExpectation
- func (m *PGXPoolMock) ExpectPrepare(name, sql string) *PoolPrepareExpectation
- func (m *PGXPoolMock) ExpectQuery(query string) *QueryExpectation
- func (m *PGXPoolMock) ExpectQueryRow(query string) *QueryRowExpectation
- func (m *PGXPoolMock) ExpectRollback() *RollbackExpectation
- func (m *PGXPoolMock) LargeObjects() pgx.LargeObjects
- func (m *PGXPoolMock) Ping(ctx context.Context) error
- func (m *PGXPoolMock) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
- func (m *PGXPoolMock) Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
- func (m *PGXPoolMock) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- func (m *PGXPoolMock) Reset()
- func (m *PGXPoolMock) Rollback(ctx context.Context) error
- func (m *PGXPoolMock) SendBatch(ctx context.Context, batch *pgx.Batch) pgx.BatchResults
- func (m *PGXPoolMock) Stat() *pgxpool.Stat
- type PingExpectation
- type PoolCopyFromExpectation
- func (e *PoolCopyFromExpectation) String() string
- func (e *PoolCopyFromExpectation) WillReturnError(err error)
- func (e *PoolCopyFromExpectation) WillReturnResult(rowsAffected int64)
- func (e *PoolCopyFromExpectation) WithArgs(args ...any)
- func (e *PoolCopyFromExpectation) WithColumns(columns []string) *PoolCopyFromExpectation
- type PoolPrepareExpectation
- func (e *PoolPrepareExpectation) String() string
- func (e *PoolPrepareExpectation) WillReturnError(err error)
- func (e *PoolPrepareExpectation) WillReturnResult(desc *pgconn.StatementDescription)
- func (e *PoolPrepareExpectation) WithArgs(args ...any)
- func (e *PoolPrepareExpectation) WithName(name string) *PoolPrepareExpectation
- type PrepareExpectation
- func (e *PrepareExpectation) String() string
- func (e *PrepareExpectation) WillReturnError(err error)
- func (e *PrepareExpectation) WillReturnResult(desc *pgconn.StatementDescription)
- func (e *PrepareExpectation) WithArgs(args ...any)
- func (e *PrepareExpectation) WithName(name string) *PrepareExpectation
- type QueryExpectation
- type QueryRowExpectation
- type RollbackExpectation
- type Row
- type Rows
- func (r *Rows) AddRow(values ...any) *Rows
- func (r *Rows) Close()
- func (r *Rows) CommandTag() pgconn.CommandTag
- func (r *Rows) Conn() *pgx.Conn
- func (r *Rows) Err() error
- func (r *Rows) FieldDescriptions() []pgconn.FieldDescription
- func (r *Rows) GetRowsForTesting() [][]any
- func (r *Rows) Next() bool
- func (r *Rows) RawValues() [][]byte
- func (r *Rows) Scan(dest ...any) error
- func (r *Rows) Values() ([]any, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoExpectation = errors.New("no expectation found")
Functions ¶
Types ¶
type AcquireAllIdleExpectation ¶
type AcquireAllIdleExpectation struct {
// contains filtered or unexported fields
}
func (*AcquireAllIdleExpectation) WillReturnConns ¶
func (e *AcquireAllIdleExpectation) WillReturnConns(conns []*pgxpool.Conn)
type AcquireExpectation ¶
type AcquireExpectation struct {
// contains filtered or unexported fields
}
func (*AcquireExpectation) WillReturnConn ¶
func (e *AcquireExpectation) WillReturnConn(conn *pgxpool.Conn)
func (*AcquireExpectation) WillReturnError ¶
func (e *AcquireExpectation) WillReturnError(err error)
type AcquireFuncExpectation ¶
type AcquireFuncExpectation struct {
// contains filtered or unexported fields
}
func (*AcquireFuncExpectation) WillReturnError ¶
func (e *AcquireFuncExpectation) WillReturnError(err error)
type BeginExpectation ¶
type BeginExpectation struct {
// contains filtered or unexported fields
}
func (*BeginExpectation) WillReturnError ¶
func (e *BeginExpectation) WillReturnError(err error)
type BeginTxExpectation ¶
type BeginTxExpectation struct {
// contains filtered or unexported fields
}
func (*BeginTxExpectation) WillReturnError ¶
func (e *BeginTxExpectation) WillReturnError(err error)
func (*BeginTxExpectation) WithOptions ¶
func (e *BeginTxExpectation) WithOptions(opts pgx.TxOptions) *BeginTxExpectation
type CloseExpectation ¶
type CloseExpectation struct {
// contains filtered or unexported fields
}
func (*CloseExpectation) WillReturnError ¶
func (e *CloseExpectation) WillReturnError(err error)
type CommitExpectation ¶
type CommitExpectation struct {
// contains filtered or unexported fields
}
func (*CommitExpectation) WillReturnError ¶
func (e *CommitExpectation) WillReturnError(err error)
type CopyFromExpectation ¶
type CopyFromExpectation struct {
// contains filtered or unexported fields
}
func (*CopyFromExpectation) WillReturnError ¶
func (e *CopyFromExpectation) WillReturnError(err error)
func (*CopyFromExpectation) WillReturnResult ¶
func (e *CopyFromExpectation) WillReturnResult(rowsAffected int64)
func (*CopyFromExpectation) WithColumns ¶
func (e *CopyFromExpectation) WithColumns(columns []string) *CopyFromExpectation
type DeallocateAllExpectation ¶
type DeallocateAllExpectation struct {
// contains filtered or unexported fields
}
func (*DeallocateAllExpectation) WillReturnError ¶
func (e *DeallocateAllExpectation) WillReturnError(err error)
type DeallocateExpectation ¶
type DeallocateExpectation struct {
// contains filtered or unexported fields
}
func (*DeallocateExpectation) WillReturnError ¶
func (e *DeallocateExpectation) WillReturnError(err error)
type ExecExpectation ¶
type ExecExpectation struct {
// contains filtered or unexported fields
}
func (*ExecExpectation) WillReturnError ¶
func (e *ExecExpectation) WillReturnError(err error)
func (*ExecExpectation) WillReturnResult ¶
func (e *ExecExpectation) WillReturnResult(res pgconn.CommandTag)
func (*ExecExpectation) WithArgs ¶
func (e *ExecExpectation) WithArgs(args ...any) *ExecExpectation
type PGXMock ¶
type PGXMock struct {
// contains filtered or unexported fields
}
PGXMock provides a mock implementation of postgres.PGXConn and pgx.Tx interfaces for testing database interactions without requiring an actual database connection.
func NewPGXMock ¶
func NewPGXMock() *PGXMock
NewPGXMock creates a new mock database connection for testing.
func (*PGXMock) AllExpectationsMet ¶
AllExpectationsMet verifies that all configured expectations have been fulfilled.
func (*PGXMock) Config ¶
func (m *PGXMock) Config() *pgx.ConnConfig
func (*PGXMock) CopyFrom ¶
func (m *PGXMock) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
func (*PGXMock) ExpectBegin ¶
func (m *PGXMock) ExpectBegin() *BeginExpectation
func (*PGXMock) ExpectBeginTx ¶
func (m *PGXMock) ExpectBeginTx() *BeginTxExpectation
func (*PGXMock) ExpectClose ¶
func (m *PGXMock) ExpectClose() *CloseExpectation
func (*PGXMock) ExpectCommit ¶
func (m *PGXMock) ExpectCommit() *CommitExpectation
func (*PGXMock) ExpectCopyFrom ¶
func (m *PGXMock) ExpectCopyFrom(tableName pgx.Identifier) *CopyFromExpectation
ExpectCopyFrom configures an expectation for bulk copy operations.
func (*PGXMock) ExpectDeallocate ¶
func (m *PGXMock) ExpectDeallocate(name string) *DeallocateExpectation
func (*PGXMock) ExpectDeallocateAll ¶
func (m *PGXMock) ExpectDeallocateAll() *DeallocateAllExpectation
func (*PGXMock) ExpectExec ¶
func (m *PGXMock) ExpectExec(query string) *ExecExpectation
ExpectExec configures an expectation for an Exec operation with the specified query.
func (*PGXMock) ExpectPing ¶
func (m *PGXMock) ExpectPing() *PingExpectation
func (*PGXMock) ExpectPrepare ¶
func (m *PGXMock) ExpectPrepare(name, sql string) *PrepareExpectation
ExpectPrepare configures an expectation for preparing a statement.
func (*PGXMock) ExpectQuery ¶
func (m *PGXMock) ExpectQuery(query string) *QueryExpectation
ExpectQuery configures an expectation for a Query operation with the specified query.
func (*PGXMock) ExpectQueryRow ¶
func (m *PGXMock) ExpectQueryRow(query string) *QueryRowExpectation
ExpectQueryRow configures an expectation for a QueryRow operation with the specified query.
func (*PGXMock) ExpectRollback ¶
func (m *PGXMock) ExpectRollback() *RollbackExpectation
func (*PGXMock) LargeObjects ¶
func (m *PGXMock) LargeObjects() pgx.LargeObjects
type PGXPoolMock ¶
type PGXPoolMock struct {
// contains filtered or unexported fields
}
PGXPoolMock provides a mock implementation of postgres.PGXPool and pgx.Tx interfaces for testing database pool interactions without requiring an actual database connection.
func NewPGXPoolMock ¶
func NewPGXPoolMock() *PGXPoolMock
NewPGXPoolMock creates a new mock database connection pool for testing.
func (*PGXPoolMock) AcquireAllIdle ¶
func (m *PGXPoolMock) AcquireAllIdle(ctx context.Context) []*pgxpool.Conn
func (*PGXPoolMock) AcquireFunc ¶
AcquireFunc executes fn with a nil connection for mock purposes.
func (*PGXPoolMock) AllExpectationsMet ¶
func (m *PGXPoolMock) AllExpectationsMet() error
AllExpectationsMet verifies that all configured expectations have been fulfilled.
func (*PGXPoolMock) Close ¶
func (m *PGXPoolMock) Close()
func (*PGXPoolMock) Config ¶
func (m *PGXPoolMock) Config() *pgxpool.Config
func (*PGXPoolMock) Conn ¶
func (m *PGXPoolMock) Conn() *pgx.Conn
func (*PGXPoolMock) CopyFrom ¶
func (m *PGXPoolMock) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
func (*PGXPoolMock) Exec ¶
func (m *PGXPoolMock) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
func (*PGXPoolMock) ExpectAcquire ¶
func (m *PGXPoolMock) ExpectAcquire() *AcquireExpectation
ExpectAcquire configures an expectation for acquiring a connection from the pool.
func (*PGXPoolMock) ExpectAcquireAllIdle ¶
func (m *PGXPoolMock) ExpectAcquireAllIdle() *AcquireAllIdleExpectation
ExpectAcquireAllIdle configures an expectation for acquiring all idle connections.
func (*PGXPoolMock) ExpectAcquireFunc ¶
func (m *PGXPoolMock) ExpectAcquireFunc() *AcquireFuncExpectation
ExpectAcquireFunc configures an expectation for AcquireFunc operations.
func (*PGXPoolMock) ExpectBegin ¶
func (m *PGXPoolMock) ExpectBegin() *BeginExpectation
func (*PGXPoolMock) ExpectBeginTx ¶
func (m *PGXPoolMock) ExpectBeginTx() *BeginTxExpectation
func (*PGXPoolMock) ExpectClose ¶
func (m *PGXPoolMock) ExpectClose() *CloseExpectation
func (*PGXPoolMock) ExpectCommit ¶
func (m *PGXPoolMock) ExpectCommit() *CommitExpectation
func (*PGXPoolMock) ExpectCopyFrom ¶
func (m *PGXPoolMock) ExpectCopyFrom(tableName pgx.Identifier) *PoolCopyFromExpectation
ExpectCopyFrom configures an expectation for bulk copy operations.
func (*PGXPoolMock) ExpectExec ¶
func (m *PGXPoolMock) ExpectExec(query string) *ExecExpectation
ExpectExec configures an expectation for an Exec operation with the specified query.
func (*PGXPoolMock) ExpectPing ¶
func (m *PGXPoolMock) ExpectPing() *PingExpectation
func (*PGXPoolMock) ExpectPrepare ¶
func (m *PGXPoolMock) ExpectPrepare(name, sql string) *PoolPrepareExpectation
ExpectPrepare configures an expectation for preparing a statement.
func (*PGXPoolMock) ExpectQuery ¶
func (m *PGXPoolMock) ExpectQuery(query string) *QueryExpectation
ExpectQuery configures an expectation for a Query operation with the specified query.
func (*PGXPoolMock) ExpectQueryRow ¶
func (m *PGXPoolMock) ExpectQueryRow(query string) *QueryRowExpectation
ExpectQueryRow configures an expectation for a QueryRow operation with the specified query.
func (*PGXPoolMock) ExpectRollback ¶
func (m *PGXPoolMock) ExpectRollback() *RollbackExpectation
func (*PGXPoolMock) LargeObjects ¶
func (m *PGXPoolMock) LargeObjects() pgx.LargeObjects
func (*PGXPoolMock) Prepare ¶
func (m *PGXPoolMock) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
func (*PGXPoolMock) Reset ¶
func (m *PGXPoolMock) Reset()
Methods that return nil/defaults for interface compliance
func (*PGXPoolMock) SendBatch ¶
func (m *PGXPoolMock) SendBatch(ctx context.Context, batch *pgx.Batch) pgx.BatchResults
func (*PGXPoolMock) Stat ¶
func (m *PGXPoolMock) Stat() *pgxpool.Stat
type PingExpectation ¶
type PingExpectation struct {
// contains filtered or unexported fields
}
func (*PingExpectation) WillReturnError ¶
func (e *PingExpectation) WillReturnError(err error)
type PoolCopyFromExpectation ¶
type PoolCopyFromExpectation struct {
// contains filtered or unexported fields
}
func (*PoolCopyFromExpectation) WillReturnError ¶
func (e *PoolCopyFromExpectation) WillReturnError(err error)
func (*PoolCopyFromExpectation) WillReturnResult ¶
func (e *PoolCopyFromExpectation) WillReturnResult(rowsAffected int64)
func (*PoolCopyFromExpectation) WithColumns ¶
func (e *PoolCopyFromExpectation) WithColumns(columns []string) *PoolCopyFromExpectation
type PoolPrepareExpectation ¶
type PoolPrepareExpectation struct {
// contains filtered or unexported fields
}
func (*PoolPrepareExpectation) WillReturnError ¶
func (e *PoolPrepareExpectation) WillReturnError(err error)
func (*PoolPrepareExpectation) WillReturnResult ¶
func (e *PoolPrepareExpectation) WillReturnResult(desc *pgconn.StatementDescription)
func (*PoolPrepareExpectation) WithName ¶
func (e *PoolPrepareExpectation) WithName(name string) *PoolPrepareExpectation
type PrepareExpectation ¶
type PrepareExpectation struct {
// contains filtered or unexported fields
}
func (*PrepareExpectation) WillReturnError ¶
func (e *PrepareExpectation) WillReturnError(err error)
func (*PrepareExpectation) WillReturnResult ¶
func (e *PrepareExpectation) WillReturnResult(desc *pgconn.StatementDescription)
func (*PrepareExpectation) WithName ¶
func (e *PrepareExpectation) WithName(name string) *PrepareExpectation
type QueryExpectation ¶
type QueryExpectation struct {
// contains filtered or unexported fields
}
func (*QueryExpectation) WillReturnError ¶
func (e *QueryExpectation) WillReturnError(err error)
func (*QueryExpectation) WillReturnRows ¶
func (e *QueryExpectation) WillReturnRows(rows pgx.Rows)
func (*QueryExpectation) WithArgs ¶
func (e *QueryExpectation) WithArgs(args ...any) *QueryExpectation
type QueryRowExpectation ¶
type QueryRowExpectation struct {
// contains filtered or unexported fields
}
func (*QueryRowExpectation) WillReturnRow ¶
func (e *QueryRowExpectation) WillReturnRow(row pgx.Row)
func (*QueryRowExpectation) WithArgs ¶
func (e *QueryRowExpectation) WithArgs(args ...any) *QueryRowExpectation
type RollbackExpectation ¶
type RollbackExpectation struct {
// contains filtered or unexported fields
}
func (*RollbackExpectation) WillReturnError ¶
func (e *RollbackExpectation) WillReturnError(err error)
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row provides a mock implementation of pgx.Row for testing QueryRow operations.
func (*Row) WillReturnError ¶
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows provides a mock implementation of pgx.Rows for testing Query operations. Supports adding rows and controlling iteration behavior.
func (*Rows) CommandTag ¶
func (r *Rows) CommandTag() pgconn.CommandTag
func (*Rows) FieldDescriptions ¶
func (r *Rows) FieldDescriptions() []pgconn.FieldDescription
func (*Rows) GetRowsForTesting ¶
GetRowsForTesting exposes internal row data for test verification.