Skip to content

Commit

Permalink
Adds fix to before go 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
IvoGoman committed Aug 1, 2022
1 parent 37b1bab commit 7c9a431
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions expectations_before_go18.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ func (e *ExpectedQuery) WillReturnRows(rows *Rows) *ExpectedQuery {

func (e *queryBasedExpectation) argsMatches(args []namedValue) error {
if nil == e.args {
if len(args) > 0 {
return fmt.Errorf("expected 0, but got %d arguments", len(args))
}
return nil
}
if len(args) != len(e.args) {
Expand Down
4 changes: 2 additions & 2 deletions expectations_before_go18_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
func TestQueryExpectationArgComparison(t *testing.T) {
e := &queryBasedExpectation{converter: driver.DefaultParameterConverter}
against := []namedValue{{Value: int64(5), Ordinal: 1}}
if err := e.argsMatches(against); err != nil {
t.Errorf("arguments should match, since the no expectation was set, but got err: %s", err)
if err := e.argsMatches(against); err == nil {
t.Error("arguments should not match, since no expectation was set, but argument was passed")
}

e.args = []driver.Value{5, "str"}
Expand Down
2 changes: 1 addition & 1 deletion expectations_go18_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestQueryExpectationArgComparison(t *testing.T) {
e := &queryBasedExpectation{converter: driver.DefaultParameterConverter}
against := []driver.NamedValue{{Value: int64(5), Ordinal: 1}}
if err := e.argsMatches(against); err == nil {
t.Errorf("arguments should not match, since no expectation was set, but argument was passed")
t.Error("arguments should not match, since no expectation was set, but argument was passed")
}

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

0 comments on commit 7c9a431

Please sign in to comment.