Alerting: Add context.Context to RuleStore (#45004)

Alerting: Add context.Context to RuleStore
This commit is contained in:
George Robinson
2022-02-08 08:52:03 +00:00
committed by GitHub
parent 31ba5bfea0
commit a9399ab3cd
13 changed files with 108 additions and 96 deletions

View File

@@ -4,6 +4,7 @@
package store_test
import (
"context"
"testing"
"time"
@@ -26,20 +27,21 @@ func mockTimeNow() {
}
func TestAlertInstanceOperations(t *testing.T) {
ctx := context.Background()
_, dbstore := tests.SetupTestEnv(t, baseIntervalSeconds)
const mainOrgID int64 = 1
alertRule1 := tests.CreateTestAlertRule(t, dbstore, 60, mainOrgID)
alertRule1 := tests.CreateTestAlertRule(t, ctx, dbstore, 60, mainOrgID)
orgID := alertRule1.OrgID
alertRule2 := tests.CreateTestAlertRule(t, dbstore, 60, mainOrgID)
alertRule2 := tests.CreateTestAlertRule(t, ctx, dbstore, 60, mainOrgID)
require.Equal(t, orgID, alertRule2.OrgID)
alertRule3 := tests.CreateTestAlertRule(t, dbstore, 60, mainOrgID)
alertRule3 := tests.CreateTestAlertRule(t, ctx, dbstore, 60, mainOrgID)
require.Equal(t, orgID, alertRule3.OrgID)
alertRule4 := tests.CreateTestAlertRule(t, dbstore, 60, mainOrgID)
alertRule4 := tests.CreateTestAlertRule(t, ctx, dbstore, 60, mainOrgID)
require.Equal(t, orgID, alertRule4.OrgID)
t.Run("can save and read new alert instance", func(t *testing.T) {