@@ -17,46 +17,45 @@ func (m matcher) Match(driver.Value) bool {
1717
1818func TestQueryExpectationArgComparison (t * testing.T ) {
1919 e := & queryBasedExpectation {}
20- against := []driver.Value {5 }
21- if ! e .argsMatches (against ) {
22- t .Error ("arguments should match, since the no expectation was set" )
20+ against := []driver.Value {int64 ( 5 ) }
21+ if err := e .argsMatches (against ); err != nil {
22+ t .Errorf ("arguments should match, since the no expectation was set, but got err: %s" , err )
2323 }
2424
2525 e .args = []driver.Value {5 , "str" }
2626
27- against = []driver.Value {5 }
28- if e .argsMatches (against ) {
27+ against = []driver.Value {int64 ( 5 ) }
28+ if err := e .argsMatches (against ); err == nil {
2929 t .Error ("arguments should not match, since the size is not the same" )
3030 }
3131
32- against = []driver.Value {3 , "str" }
33- if e .argsMatches (against ) {
32+ against = []driver.Value {int64 ( 3 ) , "str" }
33+ if err := e .argsMatches (against ); err == nil {
3434 t .Error ("arguments should not match, since the first argument (int value) is different" )
3535 }
3636
37- against = []driver.Value {5 , "st" }
38- if e .argsMatches (against ) {
37+ against = []driver.Value {int64 ( 5 ) , "st" }
38+ if err := e .argsMatches (against ); err == nil {
3939 t .Error ("arguments should not match, since the second argument (string value) is different" )
4040 }
4141
42- against = []driver.Value {5 , "str" }
43- if ! e .argsMatches (against ) {
44- t .Error ("arguments should match, but it did not" )
42+ against = []driver.Value {int64 ( 5 ) , "str" }
43+ if err := e .argsMatches (against ); err != nil {
44+ t .Errorf ("arguments should match, but it did not: %s" , err )
4545 }
4646
47- e .args = []driver.Value {5 , time .Now ()}
48-
4947 const longForm = "Jan 2, 2006 at 3:04pm (MST)"
5048 tm , _ := time .Parse (longForm , "Feb 3, 2013 at 7:54pm (PST)" )
49+ e .args = []driver.Value {5 , tm }
5150
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" )
51+ against = []driver.Value {int64 ( 5 ) , tm }
52+ if err := e .argsMatches (against ); err != nil {
53+ t .Error ("arguments should match, but it did not" )
5554 }
5655
57- against = []driver.Value {5 , matcher {}}
58- if ! e .argsMatches (against ) {
59- t .Error ("arguments should match, but it did not" )
56+ e . args = []driver.Value {5 , matcher {}}
57+ if err := e .argsMatches (against ); err != nil {
58+ t .Errorf ("arguments should match, but it did not: %s" , err )
6059 }
6160}
6261
@@ -65,25 +64,25 @@ func TestQueryExpectationArgComparisonBool(t *testing.T) {
6564
6665 e = & queryBasedExpectation {args : []driver.Value {true }}
6766 against := []driver.Value {true }
68- if ! e .argsMatches (against ) {
67+ if err := e .argsMatches (against ); err != nil {
6968 t .Error ("arguments should match, since arguments are the same" )
7069 }
7170
7271 e = & queryBasedExpectation {args : []driver.Value {false }}
7372 against = []driver.Value {false }
74- if ! e .argsMatches (against ) {
73+ if err := e .argsMatches (against ); err != nil {
7574 t .Error ("arguments should match, since argument are the same" )
7675 }
7776
7877 e = & queryBasedExpectation {args : []driver.Value {true }}
7978 against = []driver.Value {false }
80- if e .argsMatches (against ) {
79+ if err := e .argsMatches (against ); err == nil {
8180 t .Error ("arguments should not match, since argument is different" )
8281 }
8382
8483 e = & queryBasedExpectation {args : []driver.Value {false }}
8584 against = []driver.Value {true }
86- if e .argsMatches (against ) {
85+ if err := e .argsMatches (against ); err == nil {
8786 t .Error ("arguments should not match, since argument is different" )
8887 }
8988}
0 commit comments