Replace AddHandler with AddHandlerCtx in tests (#42585)
This commit is contained in:
@@ -18,7 +18,7 @@ func TestAlertingUsageStats(t *testing.T) {
|
||||
Bus: bus.New(),
|
||||
}
|
||||
|
||||
ae.Bus.AddHandler(func(query *models.GetAllAlertsQuery) error {
|
||||
ae.Bus.AddHandlerCtx(func(ctx context.Context, query *models.GetAllAlertsQuery) error {
|
||||
var createFake = func(file string) *simplejson.Json {
|
||||
// Ignore gosec warning G304 since it's a test
|
||||
// nolint:gosec
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestEngineProcessJob(t *testing.T) {
|
||||
job := &Job{running: true, Rule: &Rule{}}
|
||||
|
||||
t.Run("Should register usage metrics func", func(t *testing.T) {
|
||||
bus.AddHandler(func(q *models.GetAllAlertsQuery) error {
|
||||
bus.AddHandlerCtx(func(ctx context.Context, q *models.GetAllAlertsQuery) error {
|
||||
settings, err := simplejson.NewJson([]byte(`{"conditions": [{"query": { "datasourceId": 1}}]}`))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -62,7 +62,7 @@ func TestEngineProcessJob(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler(func(q *models.GetDataSourceQuery) error {
|
||||
bus.AddHandlerCtx(func(ctx context.Context, q *models.GetDataSourceQuery) error {
|
||||
q.Result = &models.DataSource{Id: 1, Type: models.DS_PROMETHEUS}
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -24,12 +24,12 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
influxDBDs := &models.DataSource{Id: 16, OrgId: 1, Name: "InfluxDB", Uid: "InfluxDB-uid"}
|
||||
prom := &models.DataSource{Id: 17, OrgId: 1, Name: "Prometheus", Uid: "Prometheus-uid"}
|
||||
|
||||
bus.AddHandler("test", func(query *models.GetDefaultDataSourceQuery) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, query *models.GetDefaultDataSourceQuery) error {
|
||||
query.Result = defaultDs
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(query *models.GetDataSourceQuery) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, query *models.GetDataSourceQuery) error {
|
||||
if query.Name == defaultDs.Name || query.Uid == defaultDs.Uid {
|
||||
query.Result = defaultDs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user