File tree Expand file tree Collapse file tree 4 files changed +27
-16
lines changed
Expand file tree Collapse file tree 4 files changed +27
-16
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,8 @@ It only asserts that argument is of `time.Time` type.
188188
189189## Changes
190190
191-
191+ - ** 2016-02-23** - added ** sqlmock.AnyArg()** function to provide any kind
192+ of argument matcher.
192193- ** 2016-02-23** - convert expected arguments to driver.Value as natural
193194 driver does, the change may affect time.Time comparison and will be
194195 stricter. See [ issue] ( https://github.com/DATA-DOG/go-sqlmock/issues/31 ) .
Original file line number Diff line number Diff line change 1+ package sqlmock
2+
3+ import "database/sql/driver"
4+
5+ // Argument interface allows to match
6+ // any argument in specific way when used with
7+ // ExpectedQuery and ExpectedExec expectations.
8+ type Argument interface {
9+ Match (driver.Value ) bool
10+ }
11+
12+ // AnyArg will return an Argument which can
13+ // match any kind of arguments.
14+ //
15+ // Useful for time.Time or similar kinds of arguments.
16+ func AnyArg () Argument {
17+ return anyArgument {}
18+ }
19+
20+ type anyArgument struct {}
21+
22+ func (a anyArgument ) Match (_ driver.Value ) bool {
23+ return true
24+ }
Original file line number Diff line number Diff line change @@ -8,13 +8,6 @@ import (
88 "sync"
99)
1010
11- // Argument interface allows to match
12- // any argument in specific way when used with
13- // ExpectedQuery and ExpectedExec expectations.
14- type Argument interface {
15- Match (driver.Value ) bool
16- }
17-
1811// an expectation interface
1912type expectation interface {
2013 fulfilled () bool
Original file line number Diff line number Diff line change @@ -8,13 +8,6 @@ import (
88 "time"
99)
1010
11- type matcher struct {
12- }
13-
14- func (m matcher ) Match (driver.Value ) bool {
15- return true
16- }
17-
1811func TestQueryExpectationArgComparison (t * testing.T ) {
1912 e := & queryBasedExpectation {}
2013 against := []driver.Value {int64 (5 )}
@@ -53,7 +46,7 @@ func TestQueryExpectationArgComparison(t *testing.T) {
5346 t .Error ("arguments should match, but it did not" )
5447 }
5548
56- e .args = []driver.Value {5 , matcher {} }
49+ e .args = []driver.Value {5 , AnyArg () }
5750 if err := e .argsMatches (against ); err != nil {
5851 t .Errorf ("arguments should match, but it did not: %s" , err )
5952 }
You can’t perform that action at this time.
0 commit comments