1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-17 04:30:03 +02:00
thalos/api/redis/publisher_test.go

27 lines
750 B
Go

package redis
import (
"context"
"testing"
"github.com/eosswedenorg/thalos/api"
"github.com/go-redis/redismock/v9"
"github.com/stretchr/testify/assert"
)
func TestPublisher_Write(t *testing.T) {
client, mock := redismock.NewClientMock()
pub := NewPublisher(context.Background(), 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, pub.Write(api.Channel{"test"}, []byte("some string")))
assert.NoError(t, pub.Write(api.Channel{"test2"}, []byte("some other string")))
assert.NoError(t, pub.Flush())
assert.NoError(t, mock.ExpectationsWereMet())
}