satellite/satellitedb: move tests to their domains
Testing interfaces is slightly clearer when it's in the package needing the database rather than each individual implementation. Change-Id: I10334c214a205f7e510b939b4359a2214c4e060a
This commit is contained in:
parent
e23f423107
commit
1137620baf
@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2019 Storj Labs, Inc.
|
// Copyright (C) 2019 Storj Labs, Inc.
|
||||||
// See LICENSE for copying information.
|
// See LICENSE for copying information.
|
||||||
|
|
||||||
package satellitedb_test
|
package console_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2019 Storj Labs, Inc.
|
// Copyright (C) 2019 Storj Labs, Inc.
|
||||||
// See LICENSE for copying information.
|
// See LICENSE for copying information.
|
||||||
|
|
||||||
package satellitedb_test
|
package gracefulexit_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2020 Storj Labs, Inc.
|
// Copyright (C) 2020 Storj Labs, Inc.
|
||||||
// See LICENSE for copying information.
|
// See LICENSE for copying information.
|
||||||
|
|
||||||
package satellitedb_test
|
package metainfo_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2020 Storj Labs, Inc.
|
// Copyright (C) 2020 Storj Labs, Inc.
|
||||||
// See LICENSE for copying information.
|
// See LICENSE for copying information.
|
||||||
|
|
||||||
package satellitedb_test
|
package overlay_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -186,13 +186,3 @@ func TestOperatorConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns an AuditHistoryConfig with sensible test values.
|
|
||||||
func testAuditHistoryConfig() overlay.AuditHistoryConfig {
|
|
||||||
return overlay.AuditHistoryConfig{
|
|
||||||
WindowSize: time.Hour,
|
|
||||||
TrackingPeriod: time.Hour,
|
|
||||||
GracePeriod: time.Hour,
|
|
||||||
OfflineThreshold: 0,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2020 Storj Labs, Inc.
|
// Copyright (C) 2020 Storj Labs, Inc.
|
||||||
// See LICENSE for copying information.
|
// See LICENSE for copying information.
|
||||||
|
|
||||||
package coinpayments
|
package coinpayments_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
@ -10,6 +10,9 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"storj.io/common/testcontext"
|
"storj.io/common/testcontext"
|
||||||
|
"storj.io/storj/satellite"
|
||||||
|
"storj.io/storj/satellite/payments/coinpayments"
|
||||||
|
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestListInfos(t *testing.T) {
|
func TestListInfos(t *testing.T) {
|
||||||
@ -18,24 +21,24 @@ func TestListInfos(t *testing.T) {
|
|||||||
ctx := testcontext.New(t)
|
ctx := testcontext.New(t)
|
||||||
defer ctx.Cleanup()
|
defer ctx.Cleanup()
|
||||||
|
|
||||||
payments := NewClient(Credentials{
|
payments := coinpayments.NewClient(coinpayments.Credentials{
|
||||||
PublicKey: "ask-littleskunk-on-keybase",
|
PublicKey: "ask-littleskunk-on-keybase",
|
||||||
PrivateKey: "ask-littleskunk-on-keybase",
|
PrivateKey: "ask-littleskunk-on-keybase",
|
||||||
}).Transactions()
|
}).Transactions()
|
||||||
|
|
||||||
// verify that bad ids fail
|
// verify that bad ids fail
|
||||||
infos, err := payments.ListInfos(ctx, TransactionIDList{"an_unlikely_id"})
|
infos, err := payments.ListInfos(ctx, coinpayments.TransactionIDList{"an_unlikely_id"})
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Len(t, infos, 0)
|
assert.Len(t, infos, 0)
|
||||||
|
|
||||||
// verify that ListInfos can handle more than 25 good ids
|
// verify that ListInfos can handle more than 25 good ids
|
||||||
ids := TransactionIDList{}
|
ids := coinpayments.TransactionIDList{}
|
||||||
for x := 0; x < 27; x++ {
|
for x := 0; x < 27; x++ {
|
||||||
tx, err := payments.Create(ctx,
|
tx, err := payments.Create(ctx,
|
||||||
&CreateTX{
|
&coinpayments.CreateTX{
|
||||||
Amount: *big.NewFloat(100),
|
Amount: *big.NewFloat(100),
|
||||||
CurrencyIn: CurrencySTORJ,
|
CurrencyIn: coinpayments.CurrencySTORJ,
|
||||||
CurrencyOut: CurrencySTORJ,
|
CurrencyOut: coinpayments.CurrencySTORJ,
|
||||||
BuyerEmail: "test@test.com",
|
BuyerEmail: "test@test.com",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -46,3 +49,11 @@ func TestListInfos(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, infos, 27)
|
assert.Len(t, infos, 27)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpdateSameAppliesDoesNotExplode(t *testing.T) {
|
||||||
|
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||||
|
tdb := db.StripeCoinPayments().Transactions()
|
||||||
|
assert.NoError(t, tdb.Update(ctx, nil, coinpayments.TransactionIDList{"blah", "blah"}))
|
||||||
|
assert.NoError(t, tdb.Update(ctx, nil, coinpayments.TransactionIDList{"blah", "blah"}))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2020 Storj Labs, Inc.
|
// Copyright (C) 2020 Storj Labs, Inc.
|
||||||
// See LICENSE for copying information.
|
// See LICENSE for copying information.
|
||||||
|
|
||||||
package satellitedb_test
|
package revocation_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
@ -1,23 +0,0 @@
|
|||||||
// Copyright (C) 2019 Storj Labs, Inc.
|
|
||||||
// See LICENSE for copying information.
|
|
||||||
|
|
||||||
package satellitedb_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
|
|
||||||
"storj.io/common/testcontext"
|
|
||||||
"storj.io/storj/satellite"
|
|
||||||
"storj.io/storj/satellite/payments/coinpayments"
|
|
||||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestUpdateSameAppliesDoesNotExplode(t *testing.T) {
|
|
||||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
|
||||||
tdb := db.StripeCoinPayments().Transactions()
|
|
||||||
assert.NoError(t, tdb.Update(ctx, nil, coinpayments.TransactionIDList{"blah", "blah"}))
|
|
||||||
assert.NoError(t, tdb.Update(ctx, nil, coinpayments.TransactionIDList{"blah", "blah"}))
|
|
||||||
})
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user