1
0
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:
Gediminas Morkevicius 2014-03-09 11:36:31 +02:00
commit 2e154ee410
2 changed files with 9 additions and 2 deletions

View File

@ -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
} }

View File

@ -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")
} }