Version: v0.6.2 Latest Latest

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 6 Imported by: 0




This section is empty.


This section is empty.


func NewFakeFactory

func NewFakeFactory(fakeSR *SQLRunner) mysql.SQLRunnerFactory

NewFakeFactory returns a mysql.SQLRunnerFactory but with the fake SQLRunner received as parameter


type SQLCall

type SQLCall func(query string, args ...interface{}) error

SQLCall ...

type SQLRunner

type SQLRunner struct {
	// contains filtered or unexported fields

SQLRunner implements a fake query runner that can be used for mocking in tests

func NewQueryRunner

func NewQueryRunner(allowExtraCalls bool) *SQLRunner

NewQueryRunner will create a new fake.SQLRunner

func (*SQLRunner) AddExpectedCalls

func (qr *SQLRunner) AddExpectedCalls(expectedCalls ...SQLCall)

AddExpectedCalls appends a "run" function, that will be called and discarded the next time the query runner will be used

func (*SQLRunner) AllowExtraCalls

func (qr *SQLRunner) AllowExtraCalls()

AllowExtraCalls will allow the fake query runner to be used without expecting any calls

func (*SQLRunner) AssertDSN

func (qr *SQLRunner) AssertDSN(dsn string)

AssertDSN will check that the expected DSN is set

func (*SQLRunner) AssertNoCallsLeft

func (qr *SQLRunner) AssertNoCallsLeft()

AssertNoCallsLeft can be used to assert that there are no expected remaining query runner calls

func (*SQLRunner) DisallowExtraCalls

func (qr *SQLRunner) DisallowExtraCalls()

DisallowExtraCalls will disallow the fake query runner to be used without expecting any calls

func (*SQLRunner) PurgeExpectedCalls

func (qr *SQLRunner) PurgeExpectedCalls()

PurgeExpectedCalls removes all the expected query runner calls

func (*SQLRunner) QueryExec

func (qr *SQLRunner) QueryExec(_ context.Context, query mysql.Query) error

QueryExec mock call

func (*SQLRunner) QueryRow

func (qr *SQLRunner) QueryRow(_ context.Context, query mysql.Query, _ ...interface{}) error

QueryRow mock call

func (*SQLRunner) QueryRows

func (qr *SQLRunner) QueryRows(_ context.Context, query mysql.Query) (mysql.Rows, error)

QueryRows mock call

Source Files

Jump to

Keyboard shortcuts

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