AlertingNG: Enforce unique alert definition title (non empty)/UID per organisation (#30380)

* Enforce unique alert definition title/uid per org

* Remove print statement from test

* Do not allow empty alert definition titles

* update error message on dup title

* also add title error to update

* CamelCase json properties

* Add test for title unique enforcement in updates

Co-authored-by: kyle <kyle@grafana.com>
This commit is contained in:
Sofia Papagiannaki
2021-01-19 19:11:11 +02:00
committed by GitHub
co-authored by kyle
parent 2a55e00c78
commit b1debc9c46
8 changed files with 146 additions and 29 deletions
+2 -2
View File
@@ -40,8 +40,8 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
// RelativeTimeRange is the per query start and end time
// for requests.
type RelativeTimeRange struct {
From Duration
To Duration
From Duration `json:"from"`
To Duration `json:"to"`
}
// isValid checks that From duration is greater than To duration.
@@ -204,7 +204,6 @@ func TestAlertQuery(t *testing.T) {
err = json.Unmarshal(blob, &model)
require.NoError(t, err)
fmt.Printf(">>>>>>> %+v %+v\n", tc.alertQuery, model)
i, ok := model["datasource"]
require.True(t, ok)
datasource, ok := i.(string)