@@ -25,6 +25,10 @@ import (
25
25
"github.com/gomodule/redigo/redis"
26
26
)
27
27
28
+ var (
29
+ maxUint64Str = strconv .FormatUint (math .MaxUint64 , 10 )
30
+ )
31
+
28
32
type valueError struct {
29
33
v interface {}
30
34
err error
@@ -69,38 +73,18 @@ var replyTests = []struct {
69
73
ve (redis .Int64s ([]interface {}{int64 (4 ), int64 (5 )}, nil )),
70
74
ve ([]int64 {4 , 5 }, nil ),
71
75
},
72
- {
73
- "uint64s([uint64, uint64])" ,
74
- ve (redis .Uint64s ([]interface {}{uint64 (4 ), uint64 (5 )}, nil )),
75
- ve ([]uint64 {4 , 5 }, nil ),
76
- },
77
- {
78
- "uint64s([uint64, uint64])" ,
79
- ve (redis .Uint64s ([]interface {}{math .MaxUint64 , math .MaxUint64 }, nil )),
80
- ve ([]uint64 {math .MaxUint64 , math .MaxUint64 }, nil ),
81
- },
82
76
{
83
77
"uint64s([[]byte, []byte])" ,
84
- ve (redis .Uint64s ([]interface {}{[]byte ("4" ), []byte ("5" )}, nil )),
85
- ve ([]uint64 {4 , 5 }, nil ),
78
+ ve (redis .Uint64s ([]interface {}{[]byte (maxUint64Str ), []byte ("5" )}, nil )),
79
+ ve ([]uint64 {math . MaxUint64 , 5 }, nil ),
86
80
},
87
81
{
88
82
"Uint64Map([[]byte, []byte])" ,
89
- ve (redis .Uint64Map ([]interface {}{[]byte ("4" ), []byte ("5" )}, nil )),
90
- ve (map [string ]uint64 {"1" : 4 , "2" : 5 }, nil ),
91
- },
92
- {
93
- "Uint64Map([uint64, uint64])" ,
94
- ve (redis .Uint64Map ([]interface {}{uint64 (4 ), uint64 (5 )}, nil )),
95
- ve (map [string ]uint64 {"1" : 4 , "2" : 5 }, nil ),
96
- },
97
- {
98
- "Uint64Map([uint64, uint64])" ,
99
- ve (redis .Uint64Map ([]interface {}{math .MaxUint64 , math .MaxUint64 }, nil )),
100
- ve (map [string ]uint64 {"1" : math .MaxUint64 , "2" : math .MaxUint64 }, nil ),
83
+ ve (redis .Uint64Map ([]interface {}{[]byte ("key1" ), []byte (maxUint64Str ), []byte ("key2" ), []byte ("5" )}, nil )),
84
+ ve (map [string ]uint64 {"key1" : math .MaxUint64 , "key2" : 5 }, nil ),
101
85
},
102
86
{
103
- "strings([[]byte, []bytev2 ])" ,
87
+ "strings([[]byte, []byte ])" ,
104
88
ve (redis .Strings ([]interface {}{[]byte ("v1" ), []byte ("v2" )}, nil )),
105
89
ve ([]string {"v1" , "v2" }, nil ),
106
90
},
@@ -147,7 +131,7 @@ var replyTests = []struct {
147
131
{
148
132
"uint64(-1)" ,
149
133
ve (redis .Uint64 (int64 (- 1 ), nil )),
150
- ve (uint64 (0 ), redis .ErrNegativeInt ),
134
+ ve (uint64 (0 ), redis .ErrNegativeInt ( - 1 ) ),
151
135
},
152
136
{
153
137
"positions([[1, 2], nil, [3, 4]])" ,
@@ -171,7 +155,7 @@ func getSlowLog() (redis.SlowLog, error) {
171
155
172
156
func TestReply (t * testing.T ) {
173
157
for _ , rt := range replyTests {
174
- if rt .actual .err != rt .expected .err {
158
+ if rt .actual .err != rt .expected .err && rt . actual . err . Error () != rt . expected . err . Error () {
175
159
t .Errorf ("%s returned err %v, want %v" , rt .name , rt .actual .err , rt .expected .err )
176
160
continue
177
161
}
0 commit comments