mirror of https://github.com/go-redis/redis.git
Add Travis CI config.
This commit is contained in:
parent
4fbe517b6f
commit
be223ae3c6
|
@ -0,0 +1,13 @@
|
||||||
|
language: go
|
||||||
|
|
||||||
|
services:
|
||||||
|
- redis-server
|
||||||
|
|
||||||
|
go:
|
||||||
|
- 1.0
|
||||||
|
- 1.1
|
||||||
|
- 1.2
|
||||||
|
- tip
|
||||||
|
|
||||||
|
install:
|
||||||
|
- go get launchpad.net/gocheck
|
|
@ -60,6 +60,7 @@ func (t *RedisConnectorTest) TestTCPConnector(c *C) {
|
||||||
ping := client.Ping()
|
ping := client.Ping()
|
||||||
c.Check(ping.Err(), IsNil)
|
c.Check(ping.Err(), IsNil)
|
||||||
c.Check(ping.Val(), Equals, "PONG")
|
c.Check(ping.Val(), Equals, "PONG")
|
||||||
|
c.Assert(client.Close(), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisConnectorTest) TestUnixConnector(c *C) {
|
func (t *RedisConnectorTest) TestUnixConnector(c *C) {
|
||||||
|
@ -67,6 +68,7 @@ func (t *RedisConnectorTest) TestUnixConnector(c *C) {
|
||||||
ping := client.Ping()
|
ping := client.Ping()
|
||||||
c.Check(ping.Err(), IsNil)
|
c.Check(ping.Err(), IsNil)
|
||||||
c.Check(ping.Val(), Equals, "PONG")
|
c.Check(ping.Val(), Equals, "PONG")
|
||||||
|
c.Assert(client.Close(), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -79,8 +81,7 @@ type RedisConnPoolTest struct {
|
||||||
|
|
||||||
var _ = Suite(&RedisConnPoolTest{})
|
var _ = Suite(&RedisConnPoolTest{})
|
||||||
|
|
||||||
func (t *RedisConnPoolTest) SetUpTest(c *C) {
|
func (t *RedisConnPoolTest) SetUpSuite(c *C) {
|
||||||
if t.client == nil {
|
|
||||||
openConn := func() (net.Conn, error) {
|
openConn := func() (net.Conn, error) {
|
||||||
t.openedConnCount++
|
t.openedConnCount++
|
||||||
return net.Dial("tcp", redisAddr)
|
return net.Dial("tcp", redisAddr)
|
||||||
|
@ -97,6 +98,9 @@ func (t *RedisConnPoolTest) SetUpTest(c *C) {
|
||||||
t.client = redis.NewClient(openConn, closeConn, initConn)
|
t.client = redis.NewClient(openConn, closeConn, initConn)
|
||||||
t.client.ConnPool.(*redis.MultiConnPool).MaxCap = 10
|
t.client.ConnPool.(*redis.MultiConnPool).MaxCap = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *RedisConnPoolTest) TearDownSuite(c *C) {
|
||||||
|
c.Assert(t.client.Close(), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisConnPoolTest) TearDownTest(c *C) {
|
func (t *RedisConnPoolTest) TearDownTest(c *C) {
|
||||||
|
@ -227,8 +231,7 @@ var _ = Suite(&RedisTest{})
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
|
||||||
func (t *RedisTest) SetUpTest(c *C) {
|
func (t *RedisTest) SetUpSuite(c *C) {
|
||||||
if t.client == nil {
|
|
||||||
openConn := func() (net.Conn, error) {
|
openConn := func() (net.Conn, error) {
|
||||||
t.openedConnCount++
|
t.openedConnCount++
|
||||||
return net.Dial("tcp", redisAddr)
|
return net.Dial("tcp", redisAddr)
|
||||||
|
@ -245,6 +248,9 @@ func (t *RedisTest) SetUpTest(c *C) {
|
||||||
t.client = redis.NewClient(openConn, closeConn, initConn)
|
t.client = redis.NewClient(openConn, closeConn, initConn)
|
||||||
t.client.ConnPool.(*redis.MultiConnPool).MaxCap = 10
|
t.client.ConnPool.(*redis.MultiConnPool).MaxCap = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *RedisTest) TearDownSuite(c *C) {
|
||||||
|
c.Assert(t.client.Close(), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisTest) TearDownTest(c *C) {
|
func (t *RedisTest) TearDownTest(c *C) {
|
||||||
|
@ -323,7 +329,7 @@ func (t *RedisTest) TestManyKeys(c *C) {
|
||||||
}
|
}
|
||||||
keys := t.client.Keys("keys.*")
|
keys := t.client.Keys("keys.*")
|
||||||
c.Assert(keys.Err(), IsNil)
|
c.Assert(keys.Err(), IsNil)
|
||||||
c.Assert(keys.Val(), HasLen, 100000)
|
c.Assert(len(keys.Val()), Equals, 100000)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisTest) TestManyKeys2(c *C) {
|
func (t *RedisTest) TestManyKeys2(c *C) {
|
||||||
|
@ -337,7 +343,7 @@ func (t *RedisTest) TestManyKeys2(c *C) {
|
||||||
|
|
||||||
mget := t.client.MGet(keys...)
|
mget := t.client.MGet(keys...)
|
||||||
c.Assert(mget.Err(), IsNil)
|
c.Assert(mget.Err(), IsNil)
|
||||||
c.Assert(mget.Val(), HasLen, 100002)
|
c.Assert(len(mget.Val()), Equals, 100002)
|
||||||
vals := mget.Val()
|
vals := mget.Val()
|
||||||
for i := 0; i < 100000; i++ {
|
for i := 0; i < 100000; i++ {
|
||||||
c.Assert(vals[i+1], Equals, "hello"+strconv.Itoa(i))
|
c.Assert(vals[i+1], Equals, "hello"+strconv.Itoa(i))
|
||||||
|
@ -2554,7 +2560,7 @@ func (t *RedisTest) TestPipelineIncrFromGoroutines(c *C) {
|
||||||
|
|
||||||
reqs, err := pipeline.RunQueued()
|
reqs, err := pipeline.RunQueued()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(reqs, HasLen, 20000)
|
c.Assert(len(reqs), Equals, 20000)
|
||||||
for _, req := range reqs {
|
for _, req := range reqs {
|
||||||
if req.Err() != nil {
|
if req.Err() != nil {
|
||||||
c.Errorf("got %v, expected nil", req.Err())
|
c.Errorf("got %v, expected nil", req.Err())
|
||||||
|
@ -2691,7 +2697,7 @@ func (t *RedisTest) TestMultiExecIncrTransaction(c *C) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(reqs, HasLen, 20000)
|
c.Assert(len(reqs), Equals, 20000)
|
||||||
for _, req := range reqs {
|
for _, req := range reqs {
|
||||||
if req.Err() != nil {
|
if req.Err() != nil {
|
||||||
c.Errorf("got %v, expected nil", req.Err())
|
c.Errorf("got %v, expected nil", req.Err())
|
||||||
|
|
|
@ -63,22 +63,26 @@ type RedisConnectorTest struct{}
|
||||||
|
|
||||||
var _ = Suite(&RedisConnectorTest{})
|
var _ = Suite(&RedisConnectorTest{})
|
||||||
|
|
||||||
func (t *RedisConnectorTest) TestTCPConnector(c *C) {
|
func (t *RedisConnectorTest) TestNewTCPClient(c *C) {
|
||||||
client := redis.NewTCPClient(&redis.Options{
|
client := redis.NewTCPClient(&redis.Options{
|
||||||
Addr: ":6379",
|
Addr: ":6379",
|
||||||
})
|
})
|
||||||
ping := client.Ping()
|
ping := client.Ping()
|
||||||
c.Check(ping.Err(), IsNil)
|
c.Check(ping.Err(), IsNil)
|
||||||
c.Check(ping.Val(), Equals, "PONG")
|
c.Check(ping.Val(), Equals, "PONG")
|
||||||
|
c.Assert(client.Close(), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisConnectorTest) TestUnixConnector(c *C) {
|
func (t *RedisConnectorTest) TestNewUnixClient(c *C) {
|
||||||
|
c.Skip("not available on Travis CI")
|
||||||
|
|
||||||
client := redis.NewUnixClient(&redis.Options{
|
client := redis.NewUnixClient(&redis.Options{
|
||||||
Addr: "/tmp/redis.sock",
|
Addr: "/tmp/redis.sock",
|
||||||
})
|
})
|
||||||
ping := client.Ping()
|
ping := client.Ping()
|
||||||
c.Check(ping.Err(), IsNil)
|
c.Check(ping.Err(), IsNil)
|
||||||
c.Check(ping.Val(), Equals, "PONG")
|
c.Check(ping.Val(), Equals, "PONG")
|
||||||
|
c.Assert(client.Close(), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -235,11 +239,11 @@ func (t *RedisTest) SetUpSuite(c *C) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisTest) SetUpTest(c *C) {
|
func (t *RedisTest) TearDownSuite(c *C) {
|
||||||
t.resetRedis(c)
|
c.Assert(t.client.Close(), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisTest) TearDownTest(c *C) {
|
func (t *RedisTest) SetUpTest(c *C) {
|
||||||
t.resetRedis(c)
|
t.resetRedis(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +311,7 @@ func (t *RedisTest) TestManyKeys(c *C) {
|
||||||
}
|
}
|
||||||
keys := t.client.Keys("keys.*")
|
keys := t.client.Keys("keys.*")
|
||||||
c.Assert(keys.Err(), IsNil)
|
c.Assert(keys.Err(), IsNil)
|
||||||
c.Assert(keys.Val(), HasLen, 100000)
|
c.Assert(len(keys.Val()), Equals, 100000)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisTest) TestManyKeys2(c *C) {
|
func (t *RedisTest) TestManyKeys2(c *C) {
|
||||||
|
@ -321,7 +325,7 @@ func (t *RedisTest) TestManyKeys2(c *C) {
|
||||||
|
|
||||||
mget := t.client.MGet(keys...)
|
mget := t.client.MGet(keys...)
|
||||||
c.Assert(mget.Err(), IsNil)
|
c.Assert(mget.Err(), IsNil)
|
||||||
c.Assert(mget.Val(), HasLen, 100002)
|
c.Assert(len(mget.Val()), Equals, 100002)
|
||||||
vals := mget.Val()
|
vals := mget.Val()
|
||||||
for i := 0; i < 100000; i++ {
|
for i := 0; i < 100000; i++ {
|
||||||
c.Assert(vals[i+1], Equals, "hello"+strconv.Itoa(i))
|
c.Assert(vals[i+1], Equals, "hello"+strconv.Itoa(i))
|
||||||
|
@ -560,7 +564,8 @@ func (t *RedisTest) TestCmdKeysPExpireAt(c *C) {
|
||||||
c.Assert(set.Err(), IsNil)
|
c.Assert(set.Err(), IsNil)
|
||||||
c.Assert(set.Val(), Equals, "OK")
|
c.Assert(set.Val(), Equals, "OK")
|
||||||
|
|
||||||
pExpireAt := t.client.PExpireAt("key", time.Now().Add(900*time.Millisecond))
|
expire := 900 * time.Millisecond
|
||||||
|
pExpireAt := t.client.PExpireAt("key", time.Now().Add(expire))
|
||||||
c.Assert(pExpireAt.Err(), IsNil)
|
c.Assert(pExpireAt.Err(), IsNil)
|
||||||
c.Assert(pExpireAt.Val(), Equals, true)
|
c.Assert(pExpireAt.Val(), Equals, true)
|
||||||
|
|
||||||
|
@ -570,7 +575,8 @@ func (t *RedisTest) TestCmdKeysPExpireAt(c *C) {
|
||||||
|
|
||||||
pttl := t.client.PTTL("key")
|
pttl := t.client.PTTL("key")
|
||||||
c.Assert(pttl.Err(), IsNil)
|
c.Assert(pttl.Err(), IsNil)
|
||||||
c.Assert(pttl.Val(), Equals, 900*time.Millisecond)
|
c.Assert(pttl.Val() <= expire, Equals, true)
|
||||||
|
c.Assert(pttl.Val() >= expire-time.Millisecond, Equals, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisTest) TestCmdKeysPTTL(c *C) {
|
func (t *RedisTest) TestCmdKeysPTTL(c *C) {
|
||||||
|
@ -968,13 +974,15 @@ func (t *RedisTest) TestStringsMSetNX(c *C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RedisTest) TestStringsPSetEx(c *C) {
|
func (t *RedisTest) TestStringsPSetEx(c *C) {
|
||||||
pSetEx := t.client.PSetEx("key", 50*time.Millisecond, "hello")
|
expire := 50 * time.Millisecond
|
||||||
|
pSetEx := t.client.PSetEx("key", expire, "hello")
|
||||||
c.Assert(pSetEx.Err(), IsNil)
|
c.Assert(pSetEx.Err(), IsNil)
|
||||||
c.Assert(pSetEx.Val(), Equals, "OK")
|
c.Assert(pSetEx.Val(), Equals, "OK")
|
||||||
|
|
||||||
pttl := t.client.PTTL("key")
|
pttl := t.client.PTTL("key")
|
||||||
c.Assert(pttl.Err(), IsNil)
|
c.Assert(pttl.Err(), IsNil)
|
||||||
c.Assert(pttl.Val(), Equals, 50*time.Millisecond)
|
c.Assert(pttl.Val() <= expire, Equals, true)
|
||||||
|
c.Assert(pttl.Val() >= expire-time.Millisecond, Equals, true)
|
||||||
|
|
||||||
get := t.client.Get("key")
|
get := t.client.Get("key")
|
||||||
c.Assert(get.Err(), IsNil)
|
c.Assert(get.Err(), IsNil)
|
||||||
|
@ -2474,7 +2482,7 @@ func (t *RedisTest) TestPipelineIncr(c *C) {
|
||||||
|
|
||||||
cmds, err := pipeline.Exec()
|
cmds, err := pipeline.Exec()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(cmds, HasLen, 20000)
|
c.Assert(len(cmds), Equals, 20000)
|
||||||
for _, cmd := range cmds {
|
for _, cmd := range cmds {
|
||||||
if cmd.Err() != nil {
|
if cmd.Err() != nil {
|
||||||
c.Errorf("got %v, expected nil", cmd.Err())
|
c.Errorf("got %v, expected nil", cmd.Err())
|
||||||
|
@ -2608,7 +2616,7 @@ func (t *RedisTest) TestMultiExecIncr(c *C) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(cmds, HasLen, 20000)
|
c.Assert(len(cmds), Equals, 20000)
|
||||||
for _, cmd := range cmds {
|
for _, cmd := range cmds {
|
||||||
if cmd.Err() != nil {
|
if cmd.Err() != nil {
|
||||||
c.Errorf("got %v, expected nil", cmd.Err())
|
c.Errorf("got %v, expected nil", cmd.Err())
|
||||||
|
@ -2961,8 +2969,8 @@ func (t *RedisTest) BenchmarkRedisGet(c *C) {
|
||||||
func (t *RedisTest) BenchmarkRedisMGet(c *C) {
|
func (t *RedisTest) BenchmarkRedisMGet(c *C) {
|
||||||
c.StopTimer()
|
c.StopTimer()
|
||||||
|
|
||||||
mSet := t.client.MSet("key1", "hello1", "key2", "hello2")
|
mset := t.client.MSet("key1", "hello1", "key2", "hello2")
|
||||||
c.Assert(mSet.Err(), IsNil)
|
c.Assert(mset.Err(), IsNil)
|
||||||
|
|
||||||
c.StartTimer()
|
c.StartTimer()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue