mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2025-04-02 21:45:24 +02:00
make arg expectations optional
sometimes it's impossible to anticipate the args (such as in an insert), sometimes args don't need to be checked
This commit is contained in:
parent
5aa5d01fb9
commit
52242da115
@ -40,6 +40,9 @@ func (e *queryBasedExpectation) queryMatches(sql string) bool {
|
||||
}
|
||||
|
||||
func (e *queryBasedExpectation) argsMatches(args []driver.Value) bool {
|
||||
if nil == e.args {
|
||||
return true
|
||||
}
|
||||
if len(args) != len(e.args) {
|
||||
return false
|
||||
}
|
||||
|
@ -8,10 +8,14 @@ import (
|
||||
|
||||
func TestQueryExpectationArgComparison(t *testing.T) {
|
||||
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"}
|
||||
|
||||
against := []driver.Value{5}
|
||||
|
||||
against = []driver.Value{5}
|
||||
if e.argsMatches(against) {
|
||||
t.Error("arguments should not match, since the size is not the same")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user