Skip to content

Commit 7c9a431

Browse files
committed
Adds fix to before go 1.8
1 parent 37b1bab commit 7c9a431

3 files changed

+6
-3
lines changed

expectations_before_go18.go

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ func (e *ExpectedQuery) WillReturnRows(rows *Rows) *ExpectedQuery {
1717

1818
func (e *queryBasedExpectation) argsMatches(args []namedValue) error {
1919
if nil == e.args {
20+
if len(args) > 0 {
21+
return fmt.Errorf("expected 0, but got %d arguments", len(args))
22+
}
2023
return nil
2124
}
2225
if len(args) != len(e.args) {

expectations_before_go18_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
func TestQueryExpectationArgComparison(t *testing.T) {
1212
e := &queryBasedExpectation{converter: driver.DefaultParameterConverter}
1313
against := []namedValue{{Value: int64(5), Ordinal: 1}}
14-
if err := e.argsMatches(against); err != nil {
15-
t.Errorf("arguments should match, since the no expectation was set, but got err: %s", err)
14+
if err := e.argsMatches(against); err == nil {
15+
t.Error("arguments should not match, since no expectation was set, but argument was passed")
1616
}
1717

1818
e.args = []driver.Value{5, "str"}

expectations_go18_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestQueryExpectationArgComparison(t *testing.T) {
1313
e := &queryBasedExpectation{converter: driver.DefaultParameterConverter}
1414
against := []driver.NamedValue{{Value: int64(5), Ordinal: 1}}
1515
if err := e.argsMatches(against); err == nil {
16-
t.Errorf("arguments should not match, since no expectation was set, but argument was passed")
16+
t.Error("arguments should not match, since no expectation was set, but argument was passed")
1717
}
1818

1919
e.args = []driver.Value{5, "str"}

0 commit comments

Comments
 (0)