@@ -8,55 +8,47 @@ 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 {}
20- against := []driver.Value {5 }
21- if ! e .argsMatches (against ) {
22- t .Error ("arguments should match, since the no expectation was set" )
13+ against := []driver.Value {int64 ( 5 ) }
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 )
2316 }
2417
2518 e .args = []driver.Value {5 , "str" }
2619
27- against = []driver.Value {5 }
28- if e .argsMatches (against ) {
20+ against = []driver.Value {int64 ( 5 ) }
21+ if err := e .argsMatches (against ); err == nil {
2922 t .Error ("arguments should not match, since the size is not the same" )
3023 }
3124
32- against = []driver.Value {3 , "str" }
33- if e .argsMatches (against ) {
25+ against = []driver.Value {int64 ( 3 ) , "str" }
26+ if err := e .argsMatches (against ); err == nil {
3427 t .Error ("arguments should not match, since the first argument (int value) is different" )
3528 }
3629
37- against = []driver.Value {5 , "st" }
38- if e .argsMatches (against ) {
30+ against = []driver.Value {int64 ( 5 ) , "st" }
31+ if err := e .argsMatches (against ); err == nil {
3932 t .Error ("arguments should not match, since the second argument (string value) is different" )
4033 }
4134
42- against = []driver.Value {5 , "str" }
43- if ! e .argsMatches (against ) {
44- t .Error ("arguments should match, but it did not" )
35+ against = []driver.Value {int64 ( 5 ) , "str" }
36+ if err := e .argsMatches (against ); err != nil {
37+ t .Errorf ("arguments should match, but it did not: %s" , err )
4538 }
4639
47- e .args = []driver.Value {5 , time .Now ()}
48-
4940 const longForm = "Jan 2, 2006 at 3:04pm (MST)"
5041 tm , _ := time .Parse (longForm , "Feb 3, 2013 at 7:54pm (PST)" )
42+ e .args = []driver.Value {5 , tm }
5143
52- against = []driver.Value {5 , tm }
53- if ! e .argsMatches (against ) {
54- t .Error ("arguments should match (time will be compared only by type) , but it did not" )
44+ against = []driver.Value {int64 ( 5 ) , tm }
45+ if err := e .argsMatches (against ); err != nil {
46+ t .Error ("arguments should match, but it did not" )
5547 }
5648
57- against = []driver.Value {5 , matcher {} }
58- if ! e .argsMatches (against ) {
59- t .Error ("arguments should match, but it did not" )
49+ e . args = []driver.Value {5 , AnyArg () }
50+ if err := e .argsMatches (against ); err != nil {
51+ t .Errorf ("arguments should match, but it did not: %s" , err )
6052 }
6153}
6254
@@ -65,25 +57,25 @@ func TestQueryExpectationArgComparisonBool(t *testing.T) {
6557
6658 e = & queryBasedExpectation {args : []driver.Value {true }}
6759 against := []driver.Value {true }
68- if ! e .argsMatches (against ) {
60+ if err := e .argsMatches (against ); err != nil {
6961 t .Error ("arguments should match, since arguments are the same" )
7062 }
7163
7264 e = & queryBasedExpectation {args : []driver.Value {false }}
7365 against = []driver.Value {false }
74- if ! e .argsMatches (against ) {
66+ if err := e .argsMatches (against ); err != nil {
7567 t .Error ("arguments should match, since argument are the same" )
7668 }
7769
7870 e = & queryBasedExpectation {args : []driver.Value {true }}
7971 against = []driver.Value {false }
80- if e .argsMatches (against ) {
72+ if err := e .argsMatches (against ); err == nil {
8173 t .Error ("arguments should not match, since argument is different" )
8274 }
8375
8476 e = & queryBasedExpectation {args : []driver.Value {false }}
8577 against = []driver.Value {true }
86- if e .argsMatches (against ) {
78+ if err := e .argsMatches (against ); err == nil {
8779 t .Error ("arguments should not match, since argument is different" )
8880 }
8981}
0 commit comments