2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-06-29 21:06:25 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package redis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
"storj.io/storj/storage/redis/redisserver"
|
|
|
|
"storj.io/storj/storage/testsuite"
|
2018-06-29 21:06:25 +01:00
|
|
|
)
|
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
func TestSuite(t *testing.T) {
|
|
|
|
addr, cleanup, err := redisserver.Start()
|
2018-06-29 21:06:25 +01:00
|
|
|
if err != nil {
|
2018-09-05 17:10:35 +01:00
|
|
|
t.Fatal(err)
|
2018-06-29 21:06:25 +01:00
|
|
|
}
|
2018-09-05 17:10:35 +01:00
|
|
|
defer cleanup()
|
2018-06-29 21:06:25 +01:00
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
client, err := NewClient(addr, "", 1)
|
2018-06-29 21:06:25 +01:00
|
|
|
if err != nil {
|
2018-09-05 17:10:35 +01:00
|
|
|
t.Fatal(err)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
testsuite.RunTests(t, client)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
func TestInvalidConnection(t *testing.T) {
|
|
|
|
_, err := NewClient("", "", 1)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("expected connection error")
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
func BenchmarkSuite(b *testing.B) {
|
|
|
|
addr, cleanup, err := redisserver.Start()
|
2018-07-31 16:23:55 +01:00
|
|
|
if err != nil {
|
2018-09-05 17:10:35 +01:00
|
|
|
b.Fatal(err)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
2018-09-05 17:10:35 +01:00
|
|
|
defer cleanup()
|
2018-07-31 16:23:55 +01:00
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
client, err := NewClient(addr, "", 1)
|
2018-07-31 16:23:55 +01:00
|
|
|
if err != nil {
|
2018-09-05 17:10:35 +01:00
|
|
|
b.Fatal(err)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
2018-09-05 17:10:35 +01:00
|
|
|
testsuite.RunBenchmarks(b, client)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|