Hackaton: Add more unit tests, take 4 (#101704)
* cloudmigration/cloudmigrationimpl: run integration tests in parallel * tsdb/mysql: run tests with actual service and instance manager * pluginsintegration/angulardetectorsprovider: reduce job interval in test * util: extract test that should only be ran with -race enabled and unskip it
This commit is contained in:
@@ -6,21 +6,17 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/services/cloudmigration"
|
||||
fakeSecrets "github.com/grafana/grafana/pkg/services/secrets/fakes"
|
||||
secretskv "github.com/grafana/grafana/pkg/services/secrets/kvstore"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/tests/testsuite"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testsuite.Run(m)
|
||||
}
|
||||
|
||||
func Test_GetAllCloudMigrationSessions(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, s := setUpTest(t)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -47,6 +43,8 @@ func Test_GetAllCloudMigrationSessions(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_CreateMigrationSession(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, s := setUpTest(t)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -77,8 +75,11 @@ func Test_CreateMigrationSession(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_GetMigrationSessionByUID(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, s := setUpTest(t)
|
||||
ctx := context.Background()
|
||||
|
||||
t.Run("find session by uid", func(t *testing.T) {
|
||||
uid := "qwerty"
|
||||
orgId := int64(1)
|
||||
@@ -114,6 +115,8 @@ func Test_DeleteMigrationSession(t *testing.T) {
|
||||
*/
|
||||
|
||||
func Test_SnapshotManagement(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, s := setUpTest(t)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -166,6 +169,8 @@ func Test_SnapshotManagement(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_SnapshotResources(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, s := setUpTest(t)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -242,6 +247,8 @@ func Test_SnapshotResources(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSnapshotList(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, s := setUpTest(t)
|
||||
// Taken from setUpTest
|
||||
sessionUID := "qwerty"
|
||||
@@ -367,7 +374,8 @@ func TestDecryptToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func setUpTest(t *testing.T) (*sqlstore.SQLStore, *sqlStore) {
|
||||
testDB := db.InitTestDB(t)
|
||||
testDB := sqlstore.NewTestStore(t)
|
||||
|
||||
s := &sqlStore{
|
||||
db: testDB,
|
||||
secretsService: fakeSecrets.FakeSecretsService{},
|
||||
|
||||
Reference in New Issue
Block a user