e1ba3931ec
this allows for setting $STORJ_METAINFO_POSTGRESQL_USE_ALT=yes if you want to use the cockroachkv implementation for metainfo against postgres Change-Id: I0c9458c83fd67ee63ef4a78351e64a80a0647408
46 lines
1012 B
Go
46 lines
1012 B
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
package postgreskv2
|
|
|
|
import (
|
|
"testing"
|
|
|
|
_ "github.com/lib/pq"
|
|
|
|
"storj.io/common/testcontext"
|
|
"storj.io/storj/private/dbutil/pgutil/pgtest"
|
|
"storj.io/storj/private/dbutil/tempdb"
|
|
"storj.io/storj/storage/postgreskv2/schema"
|
|
"storj.io/storj/storage/testsuite"
|
|
)
|
|
|
|
func newTestPostgresKV2DB(ctx *testcontext.Context, t testing.TB) (store *Client, cleanup func()) {
|
|
if *pgtest.ConnStr == "" {
|
|
t.Skipf("postgresql flag missing, example:\n-postgres-test-db=%s", pgtest.DefaultConnStr)
|
|
}
|
|
|
|
tdb, err := tempdb.OpenUnique(ctx, *pgtest.ConnStr, "test-schema")
|
|
if err != nil {
|
|
t.Fatalf("init: %+v", err)
|
|
}
|
|
|
|
err = schema.PrepareDB(tdb.DB)
|
|
if err != nil {
|
|
t.Fatalf("init: %+v", err)
|
|
}
|
|
|
|
return NewWith(tdb.DB), func() {
|
|
ctx.Check(tdb.Close)
|
|
}
|
|
}
|
|
|
|
func TestSuite(t *testing.T) {
|
|
ctx := testcontext.New(t)
|
|
defer ctx.Cleanup()
|
|
|
|
store, cleanup := newTestPostgresKV2DB(ctx, t)
|
|
defer cleanup()
|
|
|
|
testsuite.RunTests(t, store)
|
|
}
|