satellite/satellitedb/satellitedbtest: pass ctx as an argument
ctx is created in most tests, instead pass in as argument to reduce code duplication. Change-Id: I466c51c008392001129c8b007c9d6b3619935ac4
This commit is contained in:
parent
1279eeae39
commit
f3b4bf2b7c
@ -24,10 +24,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSaveBucketTallies(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
// Setup: create bucket storage tallies
|
||||
projectID := testrand.UUID()
|
||||
|
||||
@ -50,10 +47,7 @@ func TestSaveBucketTallies(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStorageNodeUsage(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
const days = 30
|
||||
|
||||
now := time.Now().UTC()
|
||||
@ -141,10 +135,7 @@ func TestStorageNodeUsage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProjectLimits(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
proj, err := db.Console().Projects().Insert(ctx, &console.Project{Name: "test", OwnerID: testrand.UUID()})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -229,10 +229,7 @@ func createBucketBandwidthRollups(ctx *testcontext.Context, satelliteDB satellit
|
||||
}
|
||||
|
||||
func TestProjectBandwidthTotal(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
pdb := db.ProjectAccounting()
|
||||
projectID := testrand.UUID()
|
||||
|
||||
@ -311,10 +308,7 @@ func TestUsageRollups(t *testing.T) {
|
||||
tallyInterval = time.Hour
|
||||
)
|
||||
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
now := time.Now()
|
||||
start := now.Add(tallyInterval * time.Duration(-tallyIntervals))
|
||||
|
||||
|
@ -62,12 +62,8 @@ func (testData *AttributionTestData) init() {
|
||||
}
|
||||
|
||||
func TestDB(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
attributionDB := db.Attribution()
|
||||
|
||||
project1, project2 := testrand.UUID(), testrand.UUID()
|
||||
partner1, partner2 := testrand.UUID(), testrand.UUID()
|
||||
|
||||
@ -95,10 +91,7 @@ func TestDB(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQueryAttribution(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
now := time.Now().UTC()
|
||||
|
||||
projectID := testrand.UUID()
|
||||
|
@ -17,10 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestApiKeysRepository(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
projects := db.Console().Projects()
|
||||
apikeys := db.Console().APIKeys()
|
||||
|
||||
|
@ -44,10 +44,7 @@ func (*discardSender) FromAddress() post.Address {
|
||||
}
|
||||
|
||||
func TestGrapqhlMutation(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
log := zaptest.NewLogger(t)
|
||||
|
||||
partnersService := rewards.NewPartnersService(
|
||||
|
@ -29,10 +29,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGraphqlQuery(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
log := zaptest.NewLogger(t)
|
||||
|
||||
partnersService := rewards.NewPartnersService(
|
||||
|
@ -18,11 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestProjectMembersRepository(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
// repositories
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // repositories
|
||||
users := db.Console().Users()
|
||||
projects := db.Console().Projects()
|
||||
projectMembers := db.Console().ProjectMembers()
|
||||
|
@ -32,11 +32,7 @@ func TestProjectsRepository(t *testing.T) {
|
||||
newDescription = "some new description"
|
||||
)
|
||||
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
// repositories
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // repositories
|
||||
users := db.Console().Users()
|
||||
projects := db.Console().Projects()
|
||||
var project *console.Project
|
||||
|
@ -25,10 +25,7 @@ func TestNewRegistrationSecret(t *testing.T) {
|
||||
userFullName = "name"
|
||||
)
|
||||
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
users := db.Console().Users()
|
||||
rptokens := db.Console().ResetPasswordTokens()
|
||||
|
||||
|
@ -21,10 +21,7 @@ import (
|
||||
|
||||
func TestUserCredits(t *testing.T) {
|
||||
t.Skip("Skip until usercredits.Create method is cockroach compatible. https://github.com/cockroachdb/cockroach/issues/42881")
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
consoleDB := db.Console()
|
||||
|
||||
user, referrer, activeOffer, defaultOffer := setupData(ctx, t, db)
|
||||
|
@ -30,10 +30,7 @@ const (
|
||||
)
|
||||
|
||||
func TestUserRepository(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
repository := db.Console().Users()
|
||||
partnerID := testrand.UUID()
|
||||
|
||||
@ -62,10 +59,7 @@ func TestUserRepository(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserEmailCase(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
for _, testCase := range []struct {
|
||||
email string
|
||||
}{
|
||||
|
@ -17,10 +17,7 @@ import (
|
||||
|
||||
func TestDowntime(t *testing.T) {
|
||||
// test basic downtime functionality
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
downtimeDB := db.DowntimeTracking()
|
||||
|
||||
now := time.Now()
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/testcontext"
|
||||
|
||||
"storj.io/storj/private/testplanet"
|
||||
|
@ -20,10 +20,7 @@ import (
|
||||
|
||||
func TestProgress(t *testing.T) {
|
||||
// test basic graceful exit progress crud
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
geDB := db.GracefulExit()
|
||||
|
||||
testData := []struct {
|
||||
@ -59,10 +56,7 @@ func TestProgress(t *testing.T) {
|
||||
|
||||
func TestTransferQueueItem(t *testing.T) {
|
||||
// test basic graceful exit transfer queue crud
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
geDB := db.GracefulExit()
|
||||
|
||||
nodeID1 := testrand.NodeID()
|
||||
|
@ -19,10 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetExitingNodes(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
cache := db.OverlayCache()
|
||||
exiting := make(map[storj.NodeID]bool)
|
||||
exitingCount := 0
|
||||
@ -90,10 +87,7 @@ func TestGetExitingNodes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGracefulExitNodesByTimeframe(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
cache := db.OverlayCache()
|
||||
exitingToday := make(map[storj.NodeID]bool)
|
||||
exitingLastWeek := make(map[storj.NodeID]bool)
|
||||
|
@ -41,10 +41,7 @@ func newTestBucket(name string, projectID uuid.UUID) storj.Bucket {
|
||||
}
|
||||
|
||||
func TestBasicBucketOperations(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
consoleDB := db.Console()
|
||||
project, err := consoleDB.Projects().Insert(ctx, &console.Project{Name: "testproject1"})
|
||||
require.NoError(t, err)
|
||||
@ -89,10 +86,7 @@ func TestListBucketsAllAllowed(t *testing.T) {
|
||||
{"non matching cursor, more", "ccc", 3, 3, true},
|
||||
{"first bucket cursor, more", "0test", 5, 5, true},
|
||||
}
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
consoleDB := db.Console()
|
||||
project, err := consoleDB.Projects().Insert(ctx, &console.Project{Name: "testproject1"})
|
||||
require.NoError(t, err)
|
||||
@ -152,10 +146,7 @@ func TestListBucketsNotAllowed(t *testing.T) {
|
||||
{"last bucket cursor, allow all", "zzz", 2, 1, false, true, map[string]struct{}{"zzz": {}}, []string{"zzz"}},
|
||||
{"empty string cursor, allow all, more", "", 5, 5, true, true, map[string]struct{}{"": {}}, []string{"123", "0test", "999", "aaa", "bbb"}},
|
||||
}
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
consoleDB := db.Console()
|
||||
project, err := consoleDB.Projects().Insert(ctx, &console.Project{Name: "testproject1"})
|
||||
require.NoError(t, err)
|
||||
|
@ -283,9 +283,7 @@ func buildBenchmarkData(ctx context.Context, b *testing.B, db satellite.DB, stor
|
||||
}
|
||||
|
||||
func TestProcessOrders(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
ordersDB := db.Orders()
|
||||
serialNum := storj.SerialNumber{1}
|
||||
serialNum2 := storj.SerialNumber{2}
|
||||
|
@ -39,10 +39,7 @@ func getTotalBandwidthInGB(ctx context.Context, accountingDB accounting.ProjectA
|
||||
// TestOrdersWriteCacheBatchLimitReached makes sure bandwidth rollup values are not written to the
|
||||
// db until the batch size is reached.
|
||||
func TestOrdersWriteCacheBatchLimitReached(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
useBatchSize := 10
|
||||
amount := (memory.MB * 500).Int64()
|
||||
projectID := testrand.UUID()
|
||||
|
@ -17,10 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSerialNumbers(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
ordersDB := db.Orders()
|
||||
|
||||
expectedBucket := []byte("bucketID")
|
||||
|
@ -17,10 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPeerIdentities(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
encode := identity.EncodePeerIdentity
|
||||
|
||||
idents := db.PeerIdentities()
|
||||
|
@ -19,10 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDB_PieceCounts(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
overlaydb := db.OverlayCache()
|
||||
|
||||
type TestNode struct {
|
||||
|
@ -28,10 +28,7 @@ import (
|
||||
func TestCache_Database(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
testCache(ctx, t, db.OverlayCache())
|
||||
})
|
||||
}
|
||||
@ -174,10 +171,7 @@ func TestRandomizedSelection(t *testing.T) {
|
||||
numNodesToSelect := 100
|
||||
minSelectCount := 3 // TODO: compute this limit better
|
||||
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
cache := db.OverlayCache()
|
||||
allIDs := make(storj.NodeIDList, totalNodes)
|
||||
nodeCounts := make(map[storj.NodeID]int)
|
||||
@ -347,11 +341,7 @@ func TestKnownReliable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateCheckIn(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
// setup
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // setup
|
||||
nodeID := storj.NodeID{1, 2, 3}
|
||||
expectedEmail := "test@email.com"
|
||||
expectedAddress := "1.2.4.4"
|
||||
@ -499,10 +489,7 @@ func TestUpdateCheckIn(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCache_DowntimeTracking(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
cache := db.OverlayCache()
|
||||
defaults := overlay.NodeSelectionConfig{
|
||||
AuditReputationAlpha0: 1,
|
||||
@ -559,11 +546,7 @@ func TestCache_DowntimeTracking(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSuccesfulNodesNotCheckedInSince(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
// setup
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // setup
|
||||
info1 := getNodeInfo(testrand.NodeID())
|
||||
info2 := getNodeInfo(testrand.NodeID())
|
||||
|
||||
|
@ -20,16 +20,10 @@ import (
|
||||
)
|
||||
|
||||
func TestStatDB(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
testDatabase(ctx, t, db.OverlayCache())
|
||||
})
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
testDatabase(ctx, t, overlay.NewCombinedCache(db.OverlayCache()))
|
||||
})
|
||||
}
|
||||
|
@ -21,10 +21,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCouponRepository(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
couponsRepo := db.StripeCoinPayments().Coupons()
|
||||
coupon := payments.Coupon{
|
||||
Duration: 2,
|
||||
@ -105,10 +102,7 @@ func TestCouponRepository(t *testing.T) {
|
||||
// 8. Populating coupons again. For 6 users above. Only 1 new coupon should be added.
|
||||
// Three new coupons total should be added by 2 runs of PopulatePromotionalCoupons method.
|
||||
func TestPopulatePromotionalCoupons(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
usersRepo := db.Console().Users()
|
||||
projectsRepo := db.Console().Projects()
|
||||
couponsRepo := db.StripeCoinPayments().Coupons()
|
||||
|
@ -19,10 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCustomersRepository(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
customers := db.StripeCoinPayments().Customers()
|
||||
|
||||
customerID := "customerID"
|
||||
@ -48,10 +45,7 @@ func TestCustomersRepository(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCustomersRepositoryList(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
customersDB := db.StripeCoinPayments().Customers()
|
||||
|
||||
const custLen = 5
|
||||
|
@ -18,10 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestProjectRecords(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
utc := time.Now().UTC()
|
||||
|
||||
prjID, err := uuid.New()
|
||||
@ -70,10 +67,7 @@ func TestProjectRecords(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProjectRecordsList(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
utc := time.Now().UTC()
|
||||
|
||||
start := time.Date(utc.Year(), utc.Month(), 1, 0, 0, 0, 0, time.UTC)
|
||||
|
@ -23,10 +23,7 @@ import (
|
||||
)
|
||||
|
||||
func TestTransactionsDB(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
transactions := db.StripeCoinPayments().Transactions()
|
||||
|
||||
amount, ok := new(big.Float).SetPrec(1000).SetString("2.0000000000000000005")
|
||||
@ -151,7 +148,7 @@ func TestTransactionsDBList(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("pending transactions", func(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
for _, tx := range txs {
|
||||
_, err := db.StripeCoinPayments().Transactions().Insert(ctx, tx)
|
||||
require.NoError(t, err)
|
||||
@ -173,7 +170,7 @@ func TestTransactionsDBList(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("unapplied transaction", func(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
var updatedTxs []stripecoinpayments.Transaction
|
||||
var updates []stripecoinpayments.TransactionUpdate
|
||||
var applies coinpayments.TransactionIDList
|
||||
@ -216,10 +213,7 @@ func TestTransactionsDBList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTransactionsDBRates(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
transactions := db.StripeCoinPayments().Transactions()
|
||||
|
||||
val, ok := new(big.Float).SetPrec(1000).SetString("4.0000000000000000005")
|
||||
|
@ -18,10 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestIrreparable(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
irrdb := db.Irreparable()
|
||||
|
||||
// Create and insert test segment infos into DB
|
||||
|
@ -20,10 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func TestUntilEmpty(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
repairQueue := db.RepairQueue()
|
||||
|
||||
// insert a bunch of segments
|
||||
@ -53,10 +50,7 @@ func TestUntilEmpty(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrder(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
repairQueue := db.RepairQueue()
|
||||
|
||||
nullPath := []byte("/path/null")
|
||||
@ -120,10 +114,7 @@ func TestOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCount(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
repairQueue := db.RepairQueue()
|
||||
|
||||
// insert a bunch of segments
|
||||
|
@ -19,10 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestInsertSelect(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
q := db.RepairQueue()
|
||||
|
||||
seg := &pb.InjuredSegment{
|
||||
@ -40,10 +37,7 @@ func TestInsertSelect(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInsertDuplicate(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
q := db.RepairQueue()
|
||||
|
||||
seg := &pb.InjuredSegment{
|
||||
@ -58,10 +52,7 @@ func TestInsertDuplicate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDequeueEmptyQueue(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
q := db.RepairQueue()
|
||||
|
||||
_, err := q.Select(ctx)
|
||||
@ -71,10 +62,7 @@ func TestDequeueEmptyQueue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSequential(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
q := db.RepairQueue()
|
||||
|
||||
const N = 100
|
||||
@ -112,10 +100,7 @@ func TestSequential(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParallel(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
q := db.RepairQueue()
|
||||
const N = 100
|
||||
entries := make(chan *pb.InjuredSegment, N)
|
||||
|
@ -19,10 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestUsers(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
consoleDB := db.Console()
|
||||
|
||||
// create user
|
||||
|
@ -17,10 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestConsoleTx(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
dbConsole := db.Console()
|
||||
|
||||
t.Run("WithTx with success", func(t *testing.T) {
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"storj.io/common/testcontext"
|
||||
|
||||
"storj.io/storj/private/dbutil"
|
||||
@ -161,7 +162,7 @@ func CreatePointerDBOnTopOf(ctx context.Context, log *zap.Logger, tempDB *dbutil
|
||||
|
||||
// Run method will iterate over all supported databases. Will establish
|
||||
// connection and will create tables for each DB.
|
||||
func Run(t *testing.T, test func(t *testing.T, db satellite.DB)) {
|
||||
func Run(t *testing.T, test func(ctx *testcontext.Context, t *testing.T, db satellite.DB)) {
|
||||
for _, dbInfo := range Databases() {
|
||||
dbInfo := dbInfo
|
||||
t.Run(dbInfo.MasterDB.Name+"/"+dbInfo.PointerDB.Name, func(t *testing.T) {
|
||||
@ -191,7 +192,7 @@ func Run(t *testing.T, test func(t *testing.T, db satellite.DB)) {
|
||||
}
|
||||
|
||||
// TODO: pass the ctx down
|
||||
test(t, db)
|
||||
test(ctx, t, db)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,12 @@ package satellitedbtest_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
)
|
||||
|
||||
func TestDatabase(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
})
|
||||
}
|
||||
|
@ -510,4 +510,3 @@ func Schema() map[string]*dbschema.Schema {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user