fleet/server/pubsub/testing_utils.go
Tomas Touceda 96c0244c04
Fix redis locking receive (#1655)
* Receive redis data with timeout to not hold the connection

* Address review comments
2021-08-13 11:16:11 -03:00

31 lines
549 B
Go

package pubsub
import (
"testing"
"github.com/stretchr/testify/require"
)
func SetupRedisForTest(t *testing.T) (store *redisQueryResults, teardown func()) {
var (
addr = "127.0.0.1:6379"
password = ""
database = 0
useTLS = false
dupResults = false
)
pool, err := NewRedisPool(addr, password, database, useTLS)
require.NoError(t, err)
store = NewRedisQueryResults(pool, dupResults)
_, err = store.pool.Get().Do("PING")
require.Nil(t, err)
teardown = func() {
store.pool.Close()
}
return store, teardown
}