storj/storage/redis/client_test.go
Ivan Fraixedes c5cb4dce4d redis: Rename functions prefixed with New by Open
Rename the functions that are prefixed with 'New' which connect with
Redis by 'Open' to  make clear that they perform network operations.

Change-Id: I1351e89a642e8e2c2586626646315ad0fb2c6242
2021-03-25 06:09:27 +00:00

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 := OpenClient(ctx, redis.Addr(), "", 1)
if err != nil {
t.Fatal(err)
}
client.SetLookupLimit(500)
testsuite.RunTests(t, client)
}
func TestInvalidConnection(t *testing.T) {
_, err := OpenClient(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 := OpenClient(ctx, redis.Addr(), "", 1)
if err != nil {
b.Fatal(err)
}
testsuite.RunBenchmarks(b, client)
}