mirror of https://github.com/grafana/grafana
Alerting: Fall back to "range" query type for unified alerting when "both" is specified (#57288)
parent
616db7f68b
commit
2a36301817
@ -0,0 +1,59 @@ |
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
||||
|
||||
exports[`formValuesToRulerGrafanaRuleDTO should correctly convert rule form values 1`] = ` |
||||
Object { |
||||
"annotations": Object { |
||||
"description": "", |
||||
"runbook_url": "", |
||||
"summary": "", |
||||
}, |
||||
"for": "5m", |
||||
"grafana_alert": Object { |
||||
"condition": "A", |
||||
"data": Array [], |
||||
"exec_err_state": "Error", |
||||
"no_data_state": "NoData", |
||||
"title": "", |
||||
}, |
||||
"labels": Object { |
||||
"": "", |
||||
}, |
||||
} |
||||
`; |
||||
|
||||
exports[`formValuesToRulerGrafanaRuleDTO should not save both instant and range type queries 1`] = ` |
||||
Object { |
||||
"annotations": Object { |
||||
"description": "", |
||||
"runbook_url": "", |
||||
"summary": "", |
||||
}, |
||||
"for": "5m", |
||||
"grafana_alert": Object { |
||||
"condition": "A", |
||||
"data": Array [ |
||||
Object { |
||||
"datasourceUid": "dsuid", |
||||
"model": Object { |
||||
"expr": "", |
||||
"instant": false, |
||||
"range": true, |
||||
"refId": "A", |
||||
}, |
||||
"queryType": "query", |
||||
"refId": "A", |
||||
"relativeTimeRange": Object { |
||||
"from": 900, |
||||
"to": 1000, |
||||
}, |
||||
}, |
||||
], |
||||
"exec_err_state": "Error", |
||||
"no_data_state": "NoData", |
||||
"title": "", |
||||
}, |
||||
"labels": Object { |
||||
"": "", |
||||
}, |
||||
} |
||||
`; |
@ -0,0 +1,36 @@ |
||||
import { PromQuery } from 'app/plugins/datasource/prometheus/types'; |
||||
|
||||
import { RuleFormValues } from '../types/rule-form'; |
||||
|
||||
import { formValuesToRulerGrafanaRuleDTO, getDefaultFormValues } from './rule-form'; |
||||
|
||||
describe('formValuesToRulerGrafanaRuleDTO', () => { |
||||
it('should correctly convert rule form values', () => { |
||||
const formValues: RuleFormValues = { |
||||
...getDefaultFormValues(), |
||||
condition: 'A', |
||||
}; |
||||
|
||||
expect(formValuesToRulerGrafanaRuleDTO(formValues)).toMatchSnapshot(); |
||||
}); |
||||
|
||||
it('should not save both instant and range type queries', () => { |
||||
const defaultValues = getDefaultFormValues(); |
||||
|
||||
const values: RuleFormValues = { |
||||
...defaultValues, |
||||
queries: [ |
||||
{ |
||||
refId: 'A', |
||||
relativeTimeRange: { from: 900, to: 1000 }, |
||||
datasourceUid: 'dsuid', |
||||
model: { refId: 'A', expr: '', instant: true, range: true } as PromQuery, |
||||
queryType: 'query', |
||||
}, |
||||
], |
||||
condition: 'A', |
||||
}; |
||||
|
||||
expect(formValuesToRulerGrafanaRuleDTO(values)).toMatchSnapshot(); |
||||
}); |
||||
}); |
Loading…
Reference in new issue