fake

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFakeFactory

func NewFakeFactory(fakeSR *SQLRunner) mysql.SQLRunnerFactory

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

Types

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) AddExpectedDSN added in v0.6.3

func (qr *SQLRunner) AddExpectedDSN(expectedDSN string)

AddExpectedDSN add a expected DSN to the fake SQLRunner for later assert.

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

Jump to

Keyboard shortcuts

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