1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-26 19:21:03 +03:00

Skip flaky tests.

This commit is contained in:
Vladimir Mihailenco
2016-03-14 16:51:46 +02:00
parent 46790aa060
commit e37202e605
5 changed files with 24 additions and 15 deletions

View File

@ -13,7 +13,8 @@ var client *redis.Client
func init() {
client = redis.NewClient(&redis.Options{
Addr: ":6379",
Addr: ":6379",
DialTimeout: 10 * time.Second,
})
client.FlushDb()
}
@ -247,30 +248,32 @@ func ExamplePubSub_Receive() {
}
defer pubsub.Close()
err = client.Publish("mychannel2", "hello").Err()
n, err := client.Publish("mychannel2", "hello").Result()
if err != nil {
panic(err)
}
fmt.Println(n, "clients received message")
for i := 0; i < 2; i++ {
for {
// ReceiveTimeout is a low level API. Use ReceiveMessage instead.
msgi, err := pubsub.ReceiveTimeout(time.Second)
if err != nil {
panic(err)
break
}
switch msg := msgi.(type) {
case *redis.Subscription:
fmt.Println(msg.Kind, msg.Channel)
fmt.Println("subscribed to", msg.Channel)
case *redis.Message:
fmt.Println(msg.Channel, msg.Payload)
fmt.Println("received", msg.Payload, "from", msg.Channel)
default:
panic(fmt.Sprintf("unknown message: %#v", msgi))
panic(fmt.Errorf("unknown message: %#v", msgi))
}
}
// Output: subscribe mychannel2
// mychannel2 hello
// Output: 1 clients received message
// subscribed to mychannel2
// received hello from mychannel2
}
func ExampleScript() {