mock

package
v0.0.0-...-e8fae58 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mock is a package for mocking MySQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a struct that contains the settings for the MySQL database.

func NewDB

func NewDB() *DB

NewDB returns a new DB struct.

func (*DB) AssertAllTxCommitted

func (db *DB) AssertAllTxCommitted(t *testing.T)

AssertAllTxCommitted asserts that all transactions are committed.

func (*DB) AssertAllTxCommittedOrRolledBack

func (db *DB) AssertAllTxCommittedOrRolledBack(t *testing.T)

AssertAllTxCommittedOrRolledBack asserts that all transactions are committed or rolled back.

func (*DB) AssertAllTxRolledBack

func (db *DB) AssertAllTxRolledBack(t *testing.T)

AssertAllTxRolledBack asserts that all transactions are rolled back.

func (*DB) AssertAnyTxNotActive

func (db *DB) AssertAnyTxNotActive(t *testing.T)

AssertAnyTxNotActive asserts that any transaction is not active.

func (*DB) AssertAnyTxNotBegin

func (db *DB) AssertAnyTxNotBegin(t *testing.T)

AssertAnyTxNotBegin asserts that any transaction is not begin.

func (*DB) BeginReadOnlyTx

func (db *DB) BeginReadOnlyTx(_ context.Context) (repository.Tx, error)

BeginReadOnlyTx begins a read-only transaction.

func (*DB) BeginTx

func (db *DB) BeginTx(_ context.Context, opts *sql.TxOptions) (repository.Tx, error)

BeginTx begins a transaction.

func (*DB) Close

func (db *DB) Close() error

Close closes the database.

func (*DB) ExecContext

func (db *DB) ExecContext(_ context.Context, _ string, _ ...interface{}) (sql.Result, error)

ExecContext executes a query that doesn't return rows.

func (*DB) PrepareContext

func (db *DB) PrepareContext(_ context.Context, _ string) (*sql.Stmt, error)

PrepareContext prepares a query that returns rows.

func (*DB) QueryContext

func (db *DB) QueryContext(_ context.Context, _ string, _ ...interface{}) (*sql.Rows, error)

QueryContext executes a query that returns rows.

func (*DB) QueryRowContext

func (db *DB) QueryRowContext(_ context.Context, _ string, _ ...interface{}) *sql.Row

QueryRowContext executes a query that is expected to return at most one row.

func (*DB) Reset

func (db *DB) Reset()

Reset resets the database.

type Result

type Result struct{}

Result is a struct that contains the result of a query.

func (*Result) LastInsertId

func (*Result) LastInsertId() (int64, error)

LastInsertId returns the integer generated by the database in response to a command.

func (*Result) RowsAffected

func (*Result) RowsAffected() (int64, error)

RowsAffected returns the number of rows affected by an update, insert, or delete.

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

Tx is a struct that contains the settings for the transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) ExecContext

func (tx *Tx) ExecContext(_ context.Context, _ string, _ ...interface{}) (sql.Result, error)

ExecContext executes a query that doesn't return rows.

func (*Tx) PrepareContext

func (tx *Tx) PrepareContext(_ context.Context, _ string) (*sql.Stmt, error)

PrepareContext prepares a query that returns rows.

func (*Tx) QueryContext

func (tx *Tx) QueryContext(_ context.Context, _ string, _ ...interface{}) (*sql.Rows, error)

QueryContext executes a query that returns rows.

func (*Tx) QueryRowContext

func (tx *Tx) QueryRowContext(_ context.Context, _ string, _ ...interface{}) *sql.Row

QueryRowContext executes a query that is expected to return at most one row.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback aborts the transaction.

Jump to

Keyboard shortcuts

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