mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2025-04-23 11:58:47 +02:00
Merge pull request #3 from treetopllc/master
Optional argument expectations
This commit is contained in:
commit
2e154ee410
@ -40,6 +40,9 @@ func (e *queryBasedExpectation) queryMatches(sql string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *queryBasedExpectation) argsMatches(args []driver.Value) bool {
|
func (e *queryBasedExpectation) argsMatches(args []driver.Value) bool {
|
||||||
|
if nil == e.args {
|
||||||
|
return true
|
||||||
|
}
|
||||||
if len(args) != len(e.args) {
|
if len(args) != len(e.args) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,14 @@ import (
|
|||||||
|
|
||||||
func TestQueryExpectationArgComparison(t *testing.T) {
|
func TestQueryExpectationArgComparison(t *testing.T) {
|
||||||
e := &queryBasedExpectation{}
|
e := &queryBasedExpectation{}
|
||||||
|
against := []driver.Value{5}
|
||||||
|
if !e.argsMatches(against) {
|
||||||
|
t.Error("arguments should match, since the no expectation was set")
|
||||||
|
}
|
||||||
|
|
||||||
e.args = []driver.Value{5, "str"}
|
e.args = []driver.Value{5, "str"}
|
||||||
|
|
||||||
against := []driver.Value{5}
|
against = []driver.Value{5}
|
||||||
|
|
||||||
if e.argsMatches(against) {
|
if e.argsMatches(against) {
|
||||||
t.Error("arguments should not match, since the size is not the same")
|
t.Error("arguments should not match, since the size is not the same")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user