4c1098e571
Update the Redis dependency to use the last major production version. The last version accepts a context parameter in all the network methods so it allows us to pass it through them. Change-Id: I34121b2ec3c2728602115c724933ad24c9e6e4fd
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package redis
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"storj.io/common/testcontext"
|
|
"storj.io/storj/private/testredis"
|
|
"storj.io/storj/storage/testsuite"
|
|
)
|
|
|
|
func TestSuite(t *testing.T) {
|
|
ctx := testcontext.New(t)
|
|
defer ctx.Cleanup()
|
|
|
|
redis, err := testredis.Start(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer func() { require.NoError(t, redis.Close()) }()
|
|
|
|
client, err := NewClient(ctx, redis.Addr(), "", 1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
client.SetLookupLimit(500)
|
|
testsuite.RunTests(t, client)
|
|
}
|
|
|
|
func TestInvalidConnection(t *testing.T) {
|
|
_, err := NewClient(context.Background(), "", "", 1)
|
|
if err == nil {
|
|
t.Fatal("expected connection error")
|
|
}
|
|
}
|
|
|
|
func BenchmarkSuite(b *testing.B) {
|
|
ctx := context.Background()
|
|
|
|
redis, err := testredis.Start(ctx)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
defer func() { require.NoError(b, redis.Close()) }()
|
|
|
|
client, err := NewClient(ctx, redis.Addr(), "", 1)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
testsuite.RunBenchmarks(b, client)
|
|
}
|