Skip to content

Commit 3406aeb

Browse files
committed
Merge pull request #52 from go-redis/fix/race-build
Enable race tests.
2 parents 9778c1a + 20c738a commit 3406aeb

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
all:
22
go test gopkg.in/redis.v2 -cpu=1,2,4
3+
go test gopkg.in/redis.v2 -short -race

rate_limit_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import (
77
)
88

99
func TestRateLimiter(t *testing.T) {
10-
const n = 100000
11-
rl := newRateLimiter(time.Second, n)
10+
var n = 100000
11+
if testing.Short() {
12+
n = 1000
13+
}
14+
rl := newRateLimiter(time.Minute, n)
1215

1316
wg := &sync.WaitGroup{}
1417
for i := 0; i < n; i++ {

redis_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,21 @@ func (t *RedisTest) TestGetBigVal(c *C) {
392392
}
393393

394394
func (t *RedisTest) TestManyKeys(c *C) {
395-
for i := 0; i < 100000; i++ {
395+
var n = 100000
396+
397+
for i := 0; i < n; i++ {
396398
t.client.Set("keys.key"+strconv.Itoa(i), "hello"+strconv.Itoa(i))
397399
}
398400
keys := t.client.Keys("keys.*")
399401
c.Assert(keys.Err(), IsNil)
400-
c.Assert(len(keys.Val()), Equals, 100000)
402+
c.Assert(len(keys.Val()), Equals, n)
401403
}
402404

403405
func (t *RedisTest) TestManyKeys2(c *C) {
406+
var n = 100000
407+
404408
keys := []string{"non-existent-key"}
405-
for i := 0; i < 100000; i++ {
409+
for i := 0; i < n; i++ {
406410
key := "keys.key" + strconv.Itoa(i)
407411
t.client.Set(key, "hello"+strconv.Itoa(i))
408412
keys = append(keys, key)
@@ -411,13 +415,13 @@ func (t *RedisTest) TestManyKeys2(c *C) {
411415

412416
mget := t.client.MGet(keys...)
413417
c.Assert(mget.Err(), IsNil)
414-
c.Assert(len(mget.Val()), Equals, 100002)
418+
c.Assert(len(mget.Val()), Equals, n+2)
415419
vals := mget.Val()
416-
for i := 0; i < 100000; i++ {
420+
for i := 0; i < n; i++ {
417421
c.Assert(vals[i+1], Equals, "hello"+strconv.Itoa(i))
418422
}
419423
c.Assert(vals[0], Equals, nil)
420-
c.Assert(vals[100001], Equals, nil)
424+
c.Assert(vals[n+1], Equals, nil)
421425
}
422426

423427
func (t *RedisTest) TestStringCmdHelpers(c *C) {

0 commit comments

Comments
 (0)