mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2025-05-13 21:56:39 +02:00
Adds fix to before go 1.8
This commit is contained in:
parent
37b1bab1c0
commit
7c9a431ac4
@ -17,6 +17,9 @@ func (e *ExpectedQuery) WillReturnRows(rows *Rows) *ExpectedQuery {
|
|||||||
|
|
||||||
func (e *queryBasedExpectation) argsMatches(args []namedValue) error {
|
func (e *queryBasedExpectation) argsMatches(args []namedValue) error {
|
||||||
if nil == e.args {
|
if nil == e.args {
|
||||||
|
if len(args) > 0 {
|
||||||
|
return fmt.Errorf("expected 0, but got %d arguments", len(args))
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(args) != len(e.args) {
|
if len(args) != len(e.args) {
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
func TestQueryExpectationArgComparison(t *testing.T) {
|
func TestQueryExpectationArgComparison(t *testing.T) {
|
||||||
e := &queryBasedExpectation{converter: driver.DefaultParameterConverter}
|
e := &queryBasedExpectation{converter: driver.DefaultParameterConverter}
|
||||||
against := []namedValue{{Value: int64(5), Ordinal: 1}}
|
against := []namedValue{{Value: int64(5), Ordinal: 1}}
|
||||||
if err := e.argsMatches(against); err != nil {
|
if err := e.argsMatches(against); err == nil {
|
||||||
t.Errorf("arguments should match, since the no expectation was set, but got err: %s", err)
|
t.Error("arguments should not match, since no expectation was set, but argument was passed")
|
||||||
}
|
}
|
||||||
|
|
||||||
e.args = []driver.Value{5, "str"}
|
e.args = []driver.Value{5, "str"}
|
||||||
|
@ -13,7 +13,7 @@ func TestQueryExpectationArgComparison(t *testing.T) {
|
|||||||
e := &queryBasedExpectation{converter: driver.DefaultParameterConverter}
|
e := &queryBasedExpectation{converter: driver.DefaultParameterConverter}
|
||||||
against := []driver.NamedValue{{Value: int64(5), Ordinal: 1}}
|
against := []driver.NamedValue{{Value: int64(5), Ordinal: 1}}
|
||||||
if err := e.argsMatches(against); err == nil {
|
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"}
|
e.args = []driver.Value{5, "str"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user