|
|
|
@ -568,9 +568,22 @@ func createDatasource(t *testing.T, id int64, orgId int64, uid string) *models.D |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func createOrg(t *testing.T, id int64) *models.Org { |
|
|
|
|
t.Helper() |
|
|
|
|
return &models.Org{ |
|
|
|
|
Id: id, |
|
|
|
|
Version: 1, |
|
|
|
|
Name: fmt.Sprintf("org_%d", id), |
|
|
|
|
Created: time.Now(), |
|
|
|
|
Updated: time.Now(), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// teardown cleans the input tables between test cases.
|
|
|
|
|
func teardown(t *testing.T, x *xorm.Engine) { |
|
|
|
|
_, err := x.Exec("DELETE from alert") |
|
|
|
|
_, err := x.Exec("DELETE from org") |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
_, err = x.Exec("DELETE from alert") |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
_, err = x.Exec("DELETE from alert_notification") |
|
|
|
|
require.NoError(t, err) |
|
|
|
@ -584,6 +597,11 @@ func teardown(t *testing.T, x *xorm.Engine) { |
|
|
|
|
func setupLegacyAlertsTables(t *testing.T, x *xorm.Engine, legacyChannels []*models.AlertNotification, alerts []*models.Alert) { |
|
|
|
|
t.Helper() |
|
|
|
|
|
|
|
|
|
orgs := []models.Org{ |
|
|
|
|
*createOrg(t, 1), |
|
|
|
|
*createOrg(t, 2), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Setup dashboards.
|
|
|
|
|
dashboards := []models.Dashboard{ |
|
|
|
|
*createDashboard(t, 1, 1, "dash1-1"), |
|
|
|
@ -601,6 +619,10 @@ func setupLegacyAlertsTables(t *testing.T, x *xorm.Engine, legacyChannels []*mod |
|
|
|
|
*createDatasource(t, 3, 2, "ds3-2"), |
|
|
|
|
*createDatasource(t, 4, 2, "ds4-2"), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_, errOrgs := x.Insert(orgs) |
|
|
|
|
require.NoError(t, errOrgs) |
|
|
|
|
|
|
|
|
|
_, errDataSourcess := x.Insert(dataSources) |
|
|
|
|
require.NoError(t, errDataSourcess) |
|
|
|
|
|
|
|
|
|