mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 01:22:29 +08:00
Alerting: Add UID of rules to response that were affected by update group request (#75985)
* update storage's method InstertRules to return ids of added rules as slice to keep the same order as rules in the argument * schematize response of update rule group endpoint, add created, updated, deleted fields that contain UID of affected rules. * update integration tests to use the new fields
This commit is contained in:
@ -11,11 +11,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/resourcepermissions"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
@ -155,8 +156,10 @@ func TestIntegrationPrometheusRules(t *testing.T) {
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, resp.StatusCode, 202)
|
||||
require.JSONEq(t, `{"message":"rule group updated successfully"}`, string(b))
|
||||
assert.Equal(t, http.StatusAccepted, resp.StatusCode)
|
||||
var respModel apimodels.UpdateRuleGroupResponse
|
||||
require.NoError(t, json.Unmarshal(b, &respModel))
|
||||
require.Len(t, respModel.Created, len(rules.Rules))
|
||||
}
|
||||
|
||||
// Check that we cannot create a rule that has a panel_id and no dashboard_uid
|
||||
@ -434,8 +437,10 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, resp.StatusCode, 202)
|
||||
require.JSONEq(t, `{"message":"rule group updated successfully"}`, string(b))
|
||||
assert.Equal(t, http.StatusAccepted, resp.StatusCode)
|
||||
var respModel apimodels.UpdateRuleGroupResponse
|
||||
require.NoError(t, json.Unmarshal(b, &respModel))
|
||||
require.Len(t, respModel.Created, len(rules.Rules))
|
||||
}
|
||||
|
||||
expectedAllJSON := fmt.Sprintf(`
|
||||
|
Reference in New Issue
Block a user