28 lines
695 B
Go
28 lines
695 B
Go
package redis
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/mna/redisc/redistest"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
logrus_test "src.dualinventive.com/go/websocketserver/internal/logrus/test"
|
|
)
|
|
|
|
func TestRedisPubSubReconnect(t *testing.T) {
|
|
lt := logrus_test.NewGlobal()
|
|
|
|
rcClose, rcPorts := redistest.StartCluster(t, nil)
|
|
defer rcClose()
|
|
|
|
r, err := New([]string{":" + rcPorts[0]})
|
|
require.Nil(t, err)
|
|
defer r.Close()
|
|
|
|
// Wait here a fixed amount of time because the reconnecting occurs after connection read idle at 5 seconds
|
|
time.Sleep(10 * time.Second)
|
|
assert.True(t, strings.Contains(lt.LastEntry().Message, "reconnecting..."))
|
|
}
|