mock

package
v0.0.0-...-f03c6e0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandTag

type CommandTag struct {
	Command      string
	AffectedRows int64
}

func (CommandTag) Delete

func (ct CommandTag) Delete() bool

func (CommandTag) Insert

func (ct CommandTag) Insert() bool

func (CommandTag) RowsAffected

func (ct CommandTag) RowsAffected() int64

func (CommandTag) Select

func (ct CommandTag) Select() bool

func (CommandTag) String

func (ct CommandTag) String() string

func (CommandTag) Update

func (ct CommandTag) Update() bool

type DB

type DB struct {
	BeginCalledTimes int
	BeginCalledWith  []context.Context
	MockBegin        func(ctx context.Context) (*Tx, error)

	CloseCalledTimes int
	MockClose        func() error

	ExecCalledTimes       int
	ExecCalledWithContext []context.Context
	ExecCalledWithStmt    []string
	ExecCalledWithArgs    [][]any
	MockExec              func(ctx context.Context, stmt string, args ...any) (CommandTag, error)

	PingCalledTimes int
	PingCalledWith  []context.Context
	MockPing        func(ctx context.Context) error

	QueryCalledTimes       int
	QueryCalledWithContext []context.Context
	QueryCalledWithDst     []any
	QueryCalledWithQuery   []string
	QueryCalledWithArgs    [][]any
	MockQuery              func(ctx context.Context, dst any, query string, args ...any) error

	QueryRowCalledTimes       int
	QueryRowCalledWithContext []context.Context
	QueryRowCalledWithDst     []any
	QueryRowCalledWithQuery   []string
	QueryRowCalledWithArgs    [][]any
	MockQueryRow              func(ctx context.Context, dst any, query string, args ...any) error
	// contains filtered or unexported fields
}

func (*DB) Begin

func (db *DB) Begin(ctx context.Context) (psql.Tx, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Exec

func (db *DB) Exec(ctx context.Context, stmt string, args ...any) (psql.CommandTag, error)

func (*DB) Ping

func (db *DB) Ping(ctx context.Context) error

func (*DB) Query

func (db *DB) Query(ctx context.Context, dst any, query string, args ...any) error

func (*DB) QueryRow

func (db *DB) QueryRow(ctx context.Context, dst any, query string, args ...any) error

func (*DB) TxHistory

func (db *DB) TxHistory() []*Tx

TxHistory returns every Tx created by Begin, scrubbed of any non-assertable fields (mock functions) so as to be able to perform deep-equal, expected-to-actual assertionss.

type Tx

type Tx struct {
	CommitCalledTimes int
	CommitCalledWith  []context.Context
	MockCommit        func(ctx context.Context) error

	ExecCalledTimes       int
	ExecCalledWithContext []context.Context
	ExecCalledWithStmt    []string
	ExecCalledWithArgs    [][]any
	MockExec              func(ctx context.Context, stmt string, args ...any) (CommandTag, error)

	QueryCalledTimes       int
	QueryCalledWithContext []context.Context
	QueryCalledWithDst     []any
	QueryCalledWithQuery   []string
	QueryCalledWithArgs    [][]any
	MockQuery              func(ctx context.Context, dst any, query string, args ...any) error

	QueryRowCalledTimes       int
	QueryRowCalledWithContext []context.Context
	QueryRowCalledWithDst     []any
	QueryRowCalledWithQuery   []string
	QueryRowCalledWithArgs    [][]any
	MockQueryRow              func(ctx context.Context, dst any, query string, args ...any) error

	RollbackCalledTimes int
	RollbackCalledWith  []context.Context
	MockRollback        func(ctx context.Context) error
}

func (*Tx) Commit

func (tx *Tx) Commit(ctx context.Context) error

func (*Tx) Exec

func (tx *Tx) Exec(ctx context.Context, stmt string, args ...any) (psql.CommandTag, error)

func (*Tx) Query

func (tx *Tx) Query(ctx context.Context, dst any, query string, args ...any) error

func (*Tx) QueryRow

func (tx *Tx) QueryRow(ctx context.Context, dst any, query string, args ...any) error

func (*Tx) Rollback

func (tx *Tx) Rollback(ctx context.Context) error

Jump to

Keyboard shortcuts

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