e1a443b04a
Instead of providing the database from outside to testplanet create it inside and then allow wrapping and modifying it. This is more convenient to use. Change-Id: I9b8f69e6e0a19ff984b4e2bfe927c9100c77bc6c
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information
|
|
|
|
package testplanet
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"go.uber.org/zap/zaptest"
|
|
|
|
"storj.io/common/testcontext"
|
|
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
|
)
|
|
|
|
// Run runs testplanet in multiple configurations.
|
|
func Run(t *testing.T, config Config, test func(t *testing.T, ctx *testcontext.Context, planet *Planet)) {
|
|
for _, satelliteDB := range satellitedbtest.Databases() {
|
|
satelliteDB := satelliteDB
|
|
t.Run(satelliteDB.MasterDB.Name, func(t *testing.T) {
|
|
parallel := !config.NonParallel
|
|
if parallel {
|
|
t.Parallel()
|
|
}
|
|
|
|
ctx := testcontext.New(t)
|
|
defer ctx.Cleanup()
|
|
|
|
if satelliteDB.MasterDB.URL == "" {
|
|
t.Skipf("Database %s connection string not provided. %s", satelliteDB.MasterDB.Name, satelliteDB.MasterDB.Message)
|
|
}
|
|
planetConfig := config
|
|
if planetConfig.Name == "" {
|
|
planetConfig.Name = t.Name()
|
|
}
|
|
|
|
planet, err := NewCustom(zaptest.NewLogger(t), config, satelliteDB)
|
|
if err != nil {
|
|
t.Fatalf("%+v", err)
|
|
}
|
|
defer ctx.Check(planet.Shutdown)
|
|
|
|
planet.Start(ctx)
|
|
|
|
test(t, ctx, planet)
|
|
})
|
|
}
|
|
}
|