Alerting: Support for condition field in /api/v1/eval (#79032)
Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com>
This commit is contained in:
co-authored by
Sonia Aguilar
parent
7a38a2e48b
commit
7e331c8507
@@ -2164,6 +2164,7 @@ func TestIntegrationEval(t *testing.T) {
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": "A",
|
||||
"now": "2021-04-11T14:38:14Z"
|
||||
}
|
||||
`,
|
||||
@@ -2221,6 +2222,7 @@ func TestIntegrationEval(t *testing.T) {
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": "A",
|
||||
"now": "2021-04-11T14:38:14Z"
|
||||
}
|
||||
`,
|
||||
@@ -2276,6 +2278,7 @@ func TestIntegrationEval(t *testing.T) {
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": "A",
|
||||
"now": "2021-04-11T14:38:14Z"
|
||||
}
|
||||
`,
|
||||
@@ -2293,6 +2296,63 @@ func TestIntegrationEval(t *testing.T) {
|
||||
return "Failed to build evaluator for queries and expressions: failed to build query 'A': data source not found"
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "condition is empty",
|
||||
payload: `
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"refId": "A",
|
||||
"relativeTimeRange": {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"type":"math",
|
||||
"expression":"1 > 2"
|
||||
}
|
||||
}
|
||||
],
|
||||
"now": "2021-04-11T14:38:14Z"
|
||||
}
|
||||
`,
|
||||
expectedStatusCode: func() int { return http.StatusOK },
|
||||
expectedMessage: func() string { return "" },
|
||||
expectedResponse: func() string {
|
||||
return `{
|
||||
"results": {
|
||||
"A": {
|
||||
"status": 200,
|
||||
"frames": [
|
||||
{
|
||||
"schema": {
|
||||
"refId": "A",
|
||||
"fields": [
|
||||
{
|
||||
"name": "A",
|
||||
"type": "number",
|
||||
"typeInfo": {
|
||||
"frame": "float64",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"data": {
|
||||
"values": [
|
||||
[
|
||||
0
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}`
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user