1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-23 10:13:42 +02:00
thalos/transport/redis_pubsub/redis_test.go

26 lines
738 B
Go

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