From 859c5fb03bc4e29395eb7f2da6d212978a4623a4 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sun, 29 Jul 2012 13:02:45 +0300 Subject: [PATCH] Add test for running commands from different goroutines. --- redis_test.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/redis_test.go b/redis_test.go index b2169749..e91d6647 100644 --- a/redis_test.go +++ b/redis_test.go @@ -1426,7 +1426,7 @@ func (t *RedisTest) TestExecOnEmptyQueue(c *C) { //------------------------------------------------------------------------------ -func (t *RedisTest) TestConcAccess(c *C) { +func (t *RedisTest) TestRunningCommandsFromDifferentGoroutines(c *C) { for i := int64(0); i < 99; i++ { go func() { msg := "echo" + strconv.FormatInt(i, 10) @@ -1437,6 +1437,30 @@ func (t *RedisTest) TestConcAccess(c *C) { } } +func (t *RedisTest) TestPipeliningFromDifferentGoroutines(c *C) { + for i := int64(0); i < 99; i += 2 { + go func() { + msg1 := "echo" + strconv.FormatInt(i, 10) + msg2 := "echo" + strconv.FormatInt(i+1, 10) + + echo1Req := t.redisC.Echo(msg1) + echo2Req := t.redisC.Echo(msg2) + + reqs, err := t.redisC.RunQueued() + c.Check(reqs, HasLen, 2) + c.Check(err, IsNil) + + echo1, err := echo1Req.Reply() + c.Check(err, IsNil) + c.Check(echo1, Equals, msg1) + + echo2, err := echo2Req.Reply() + c.Check(err, IsNil) + c.Check(echo2, Equals, msg2) + }() + } +} + //------------------------------------------------------------------------------ func (t *RedisTest) BenchmarkRedisPing(c *C) {