satellite,storage: clean global ctx usage in tests
Change-Id: I89ea5c95fc6895518b464f8eb6a4c74c6ae37651
This commit is contained in:
parent
5cd6058318
commit
d3d75a597f
@ -30,7 +30,6 @@ const (
|
||||
)
|
||||
|
||||
func TestUserRepository(t *testing.T) {
|
||||
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
@ -12,11 +12,9 @@ import (
|
||||
dbx "storj.io/storj/satellite/satellitedb/dbx"
|
||||
)
|
||||
|
||||
var (
|
||||
ctx = context.Background() // test context
|
||||
)
|
||||
|
||||
func TestProjectFromDbx(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
t.Run("can't create dbo from nil dbx model", func(t *testing.T) {
|
||||
project, err := projectFromDBX(ctx, nil)
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
package satellitedb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -13,6 +14,8 @@ import (
|
||||
)
|
||||
|
||||
func TestUserFromDbx(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
t.Run("can't create dbo from nil dbx model", func(t *testing.T) {
|
||||
user, err := userFromDBX(ctx, nil)
|
||||
assert.Nil(t, user)
|
||||
|
@ -58,7 +58,7 @@ type pgAltLongBenchmarkStore struct {
|
||||
}
|
||||
|
||||
func (store *pgAltLongBenchmarkStore) BulkImport(ctx context.Context, iter storage.Iterator) error {
|
||||
return bulkImport(store.pgConn, iter)
|
||||
return bulkImport(ctx, store.pgConn, iter)
|
||||
}
|
||||
|
||||
func (store *pgAltLongBenchmarkStore) BulkDeleteAll(ctx context.Context) error {
|
||||
|
@ -18,8 +18,6 @@ import (
|
||||
"storj.io/storj/storage/testsuite"
|
||||
)
|
||||
|
||||
var ctx = context.Background() // test context
|
||||
|
||||
func newTestPostgres(t testing.TB) (store *Client, cleanup func()) {
|
||||
if *pgtest.ConnStr == "" {
|
||||
t.Skipf("postgres flag missing, example:\n-postgres-test-db=%s", pgtest.DefaultConnStr)
|
||||
@ -91,7 +89,7 @@ func BenchmarkSuite(b *testing.B) {
|
||||
testsuite.RunBenchmarks(b, store)
|
||||
}
|
||||
|
||||
func bulkImport(db *sql.DB, iter storage.Iterator) error {
|
||||
func bulkImport(ctx context.Context, db *sql.DB, iter storage.Iterator) error {
|
||||
return txutil.WithTx(ctx, db, nil, func(ctx context.Context, txn *sql.Tx) (err error) {
|
||||
stmt, err := txn.Prepare(pq.CopyIn("pathdata", "bucket", "fullpath", "metadata"))
|
||||
if err != nil {
|
||||
@ -129,8 +127,8 @@ type pgLongBenchmarkStore struct {
|
||||
*Client
|
||||
}
|
||||
|
||||
func (store *pgLongBenchmarkStore) BulkImport(iter storage.Iterator) error {
|
||||
return bulkImport(store.pgConn, iter)
|
||||
func (store *pgLongBenchmarkStore) BulkImport(ctx context.Context, iter storage.Iterator) error {
|
||||
return bulkImport(ctx, store.pgConn, iter)
|
||||
}
|
||||
|
||||
func (store *pgLongBenchmarkStore) BulkDeleteAll() error {
|
||||
|
Loading…
Reference in New Issue
Block a user