Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit c432ab0

Browse files
committed
Update tests with correct DTOs
1 parent ac1c246 commit c432ab0

File tree

1 file changed

+75
-86
lines changed

1 file changed

+75
-86
lines changed

alerting_alert_rule_test.go

Lines changed: 75 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ func TestAlertRules(t *testing.T) {
2727
server, client := gapiTestTools(t, 200, getAlertRuleGroupJSON)
2828
defer server.Close()
2929

30-
group, err := client.AlertRuleGroup("d8-gk06nz", "test")
30+
group, err := client.AlertRuleGroup("project_test", "eval_group_1")
3131

3232
if err != nil {
3333
t.Error(err)
3434
}
3535
t.Log(pretty.PrettyFormat(group))
36-
if group.Title != "test" {
37-
t.Errorf("incorrect title - expected %s got %s", "test", group.Title)
36+
if group.Title != "eval_group_1" {
37+
t.Errorf("incorrect title - expected %s got %s", "eval_group_1", group.Title)
3838
}
39-
if group.FolderUID != "d8-gk06nz" {
40-
t.Errorf("incorrect folderUID - expected %s got %s", "d8-gk06nz", group.FolderUID)
39+
if group.FolderUID != "project_test" {
40+
t.Errorf("incorrect folderUID - expected %s got %s", "project_test", group.FolderUID)
4141
}
4242
if len(group.Rules) != 1 {
4343
t.Errorf("wrong number of rules, got %d", len(group.Rules))
@@ -187,89 +187,78 @@ const getAlertRuleJSON = `
187187

188188
const getAlertRuleGroupJSON = `
189189
{
190-
"title": "test",
191-
"folderUid": "d8-gk06nz",
190+
"title": "eval_group_1",
191+
"folderUid": "project_test",
192192
"interval": 60,
193193
"rules": [
194-
{
195-
"ID": 1,
196-
"OrgID": 1,
197-
"Title": "abc",
198-
"Condition": "B",
199-
"Data": [
200-
{
201-
"refId": "A",
202-
"queryType": "",
203-
"relativeTimeRange": {
204-
"from": 600,
205-
"to": 0
194+
{
195+
"id": 212,
196+
"uid": "HW7RYci4z",
197+
"orgID": 1,
198+
"folderUID": "project_test",
199+
"ruleGroup": "eval_group_1",
200+
"title": "Always in alarm",
201+
"condition": "A",
202+
"data": [
203+
{
204+
"refId": "A",
205+
"queryType": "",
206+
"relativeTimeRange": {
207+
"from": 0,
208+
"to": 0
209+
},
210+
"datasourceUid": "-100",
211+
"model": {
212+
"datasourceUid": "-100",
213+
"intervalMs": 1000,
214+
"maxDataPoints": 43200,
215+
"model": {
216+
"conditions": [
217+
{
218+
"evaluator": {
219+
"params": [
220+
0,
221+
0
222+
],
223+
"type": "gt"
206224
},
207-
"datasourceUid": "PD8C576611E62080A",
208-
"model": {
209-
"hide": false,
210-
"intervalMs": 1000,
211-
"maxDataPoints": 43200,
212-
"refId": "A"
213-
}
214-
},
215-
{
216-
"refId": "B",
217-
"queryType": "",
218-
"relativeTimeRange": {
219-
"from": 0,
220-
"to": 0
225+
"operator": {
226+
"type": "and"
221227
},
222-
"datasourceUid": "-100",
223-
"model": {
224-
"conditions": [
225-
{
226-
"evaluator": {
227-
"params": [
228-
3
229-
],
230-
"type": "gt"
231-
},
232-
"operator": {
233-
"type": "and"
234-
},
235-
"query": {
236-
"params": [
237-
"A"
238-
]
239-
},
240-
"reducer": {
241-
"params": [],
242-
"type": "last"
243-
},
244-
"type": "query"
245-
}
246-
],
247-
"datasource": {
248-
"type": "__expr__",
249-
"uid": "-100"
250-
},
251-
"hide": false,
252-
"intervalMs": 1000,
253-
"maxDataPoints": 43200,
254-
"refId": "B",
255-
"type": "classic_conditions"
256-
}
257-
}
258-
],
259-
"Updated": "2022-07-07T16:23:56-05:00",
260-
"IntervalSeconds": 60,
261-
"Version": 1,
262-
"UID": "hsXgz0enz",
263-
"NamespaceUID": "d8-gk06nz",
264-
"DashboardUID": null,
265-
"PanelID": null,
266-
"RuleGroup": "test",
267-
"RuleGroupIndex": 1,
268-
"NoDataState": "NoData",
269-
"ExecErrState": "Alerting",
270-
"For": "1m",
271-
"Annotations": {},
272-
"Labels": {}
273-
}
228+
"query": {
229+
"params": []
230+
},
231+
"reducer": {
232+
"params": [],
233+
"type": "avg"
234+
},
235+
"type": "query"
236+
}
237+
],
238+
"datasource": {
239+
"type": "__expr__",
240+
"uid": "__expr__"
241+
},
242+
"expression": "1 == 1",
243+
"hide": false,
244+
"intervalMs": 1000,
245+
"maxDataPoints": 43200,
246+
"refId": "A",
247+
"type": "math"
248+
},
249+
"queryType": "",
250+
"refId": "A",
251+
"relativeTimeRange": {
252+
"from": 0,
253+
"to": 0
254+
}
255+
}
256+
}
257+
],
258+
"updated": "2022-08-12T15:44:43-05:00",
259+
"noDataState": "OK",
260+
"execErrState": "OK",
261+
"for": "2m"
262+
}
274263
]
275-
}`
264+
}`

0 commit comments

Comments
 (0)