1
0
mirror of https://github.com/DATA-DOG/go-sqlmock.git synced 2025-06-29 00:31:35 +02:00

allow to use a custom converter

This commit is contained in:
Jan Waś
2018-08-06 22:29:24 +02:00
parent c8e01dc244
commit f2bc8f904e
9 changed files with 96 additions and 27 deletions

View File

@ -292,6 +292,7 @@ func (e *ExpectedPrepare) WillBeClosed() *ExpectedPrepare {
func (e *ExpectedPrepare) ExpectQuery() *ExpectedQuery {
eq := &ExpectedQuery{}
eq.sqlRegex = e.sqlRegex
eq.converter = e.mock.converter
e.mock.expected = append(e.mock.expected, eq)
return eq
}
@ -301,6 +302,7 @@ func (e *ExpectedPrepare) ExpectQuery() *ExpectedQuery {
func (e *ExpectedPrepare) ExpectExec() *ExpectedExec {
eq := &ExpectedExec{}
eq.sqlRegex = e.sqlRegex
eq.converter = e.mock.converter
e.mock.expected = append(e.mock.expected, eq)
return eq
}
@ -325,8 +327,9 @@ func (e *ExpectedPrepare) String() string {
// adds a query matching logic
type queryBasedExpectation struct {
commonExpectation
sqlRegex *regexp.Regexp
args []driver.Value
sqlRegex *regexp.Regexp
converter driver.ValueConverter
args []driver.Value
}
func (e *queryBasedExpectation) attemptMatch(sql string, args []namedValue) (err error) {