Skip to content

Commit

Permalink
harden pubsub tests (#985)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>

Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun authored Oct 13, 2022
1 parent 1dcf225 commit 287ed1a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/gocase/unit/pubsub/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,24 @@ func TestPubSub(t *testing.T) {

// unsubscribe from one of the channels
require.NoError(t, pubsub.Unsubscribe(ctx, "chan1"))
require.EqualValues(t, &redis.Subscription{
Kind: "unsubscribe",
Channel: "chan1",
Count: 1,
}, receiveType(t, pubsub, &redis.Subscription{}))
require.EqualValues(t, 0, rdb.Publish(ctx, "chan1", "hello").Val())
require.EqualValues(t, 1, rdb.Publish(ctx, "chan2", "world").Val())

// drain incoming messages
receiveType(t, pubsub, &redis.Message{})

// unsubscribe from the remaining channel
require.NoError(t, pubsub.Unsubscribe(ctx, "chan2"))
require.EqualValues(t, &redis.Subscription{
Kind: "unsubscribe",
Channel: "chan2",
Count: 0,
}, receiveType(t, pubsub, &redis.Subscription{}))
require.EqualValues(t, 0, rdb.Publish(ctx, "chan1", "hello").Val())
require.EqualValues(t, 0, rdb.Publish(ctx, "chan2", "world").Val())
})
Expand Down

0 comments on commit 287ed1a

Please sign in to comment.