28 lines
547 B
Go
28 lines
547 B
Go
|
package adapter_test
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"os"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/redis/go-redis/v9"
|
||
|
"github.com/stretchr/testify/require"
|
||
|
)
|
||
|
|
||
|
func newRedisClient(tb testing.TB) *redis.Client {
|
||
|
tb.Helper()
|
||
|
|
||
|
opts, err := redis.ParseURL(os.Getenv(envRedisConnectionString))
|
||
|
require.NoError(tb, err, "couldn't parse redis connection string")
|
||
|
|
||
|
client := redis.NewClient(opts)
|
||
|
tb.Cleanup(func() {
|
||
|
_ = client.Close()
|
||
|
})
|
||
|
require.NoError(tb, retry(func() error {
|
||
|
return client.Ping(context.Background()).Err()
|
||
|
}), "couldn't ping DB")
|
||
|
|
||
|
return client
|
||
|
}
|