Documentation ¶
Index ¶
- Variables
- type Conn
- type ConnMock
- type Row
- type RowMock
- type Transactor
- type Tx
- type TxManager
- type TxManagerMock
- type TxMock
- func (_m *TxMock) Begin(ctx context.Context) (pgx.Tx, error)
- func (_m *TxMock) BeginFunc(ctx context.Context, f func(pgx.Tx) error) error
- func (_m *TxMock) Commit(ctx context.Context) error
- func (_m *TxMock) Conn() *pgx.Conn
- func (_m *TxMock) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (_m *TxMock) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
- func (_m *TxMock) LargeObjects() pgx.LargeObjects
- func (_m *TxMock) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)
- func (_m *TxMock) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (_m *TxMock) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, ...) (pgconn.CommandTag, error)
- func (_m *TxMock) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (_m *TxMock) Rollback(ctx context.Context) error
- func (_m *TxMock) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoTransaction is the error used when no transaction is found in the context. ErrNoTransaction = errors.New("no transaction in context") )
Functions ¶
This section is empty.
Types ¶
type ConnMock ¶
ConnMock is an autogenerated mock type for the Conn type
func NewConnMock ¶
NewConnMock creates a new instance of ConnMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
type RowMock ¶
RowMock is an autogenerated mock type for the RowMock type
func NewRowMock ¶
NewRowMock creates a new instance of RowMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
type Transactor ¶
type Transactor struct {
// contains filtered or unexported fields
}
Transactor is a concrete implementation of TxManagerInterface using pgxpool.
func (*Transactor) WithNestedTx ¶
func (t *Transactor) WithNestedTx(ctx context.Context, tFunc func(context.Context, Tx) error) (err error)
WithNestedTx executes a function within the context of a potentially nested transaction. It manages transaction nesting using a counter to track the depth of nested transactions. If there is no active transaction, it starts a new one.
func (*Transactor) WithTx ¶
WithTx executes a function within the context of a transaction. This method checks if there is already an ongoing transaction in the context. If not, it starts a new transaction and then executes the provided function. After the function execution, it commits the transaction if no errors occurred, or rollbacks in case of an error or panic. The transaction object is passed to the function, allowing direct transaction control.
type TxManager ¶
type TxManager interface { WithTx(ctx context.Context, fn func(context.Context, Tx) error) error WithNestedTx(ctx context.Context, tFunc func(context.Context, Tx) error) error }
TxManager defines the interface for transaction management.
type TxManagerMock ¶
TxManagerMock is an autogenerated mock type for the TxManager type
func NewTxManagerMock ¶
func NewTxManagerMock(t interface { mock.TestingT Cleanup(func()) }) *TxManagerMock
NewTxManagerMock creates a new instance of TxManagerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
type TxMock ¶
TxMock is an autogenerated mock type for the TxMock type
func NewTxMock ¶
NewTxMock creates a new instance of TxMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*TxMock) CopyFrom ¶
func (_m *TxMock) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
CopyFrom provides a mock function with given fields: ctx, tableName, columnNames, rowSrc
func (*TxMock) Exec ¶
func (_m *TxMock) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
Exec provides a mock function with given fields: ctx, sql, arguments
func (*TxMock) LargeObjects ¶
func (_m *TxMock) LargeObjects() pgx.LargeObjects
LargeObjects provides a mock function with given fields:
func (*TxMock) Prepare ¶
func (_m *TxMock) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)
Prepare provides a mock function with given fields: ctx, name, sql
func (*TxMock) QueryFunc ¶
func (_m *TxMock) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error)
QueryFunc provides a mock function with given fields: ctx, sql, args, scans, f