1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-19 04:50:02 +02:00
thalos/transport/redis_pubsub/redis_test.go

24 lines
616 B
Go

package redis_pubsub
import (
"testing"
"github.com/go-redis/redismock/v8"
"github.com/stretchr/testify/assert"
)
func TestRedisPubsub(t *testing.T) {
client, mock := redismock.NewClientMock()
pubsub := New(client)
mock.MatchExpectationsInOrder(true)
mock.ExpectPublish("test", []byte("some string")).SetVal(0)
mock.ExpectPublish("test2", []byte("some other string")).SetVal(0)
assert.NoError(t, pubsub.Publish("test", []byte("some string")))
assert.NoError(t, pubsub.Publish("test2", []byte("some other string")))
assert.NoError(t, pubsub.Flush())
assert.NoError(t, mock.ExpectationsWereMet())
}