mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: remove dead code (#43956)
This commit is contained in:
@@ -1,12 +1,6 @@
|
|||||||
import { Matcher, MatcherOperator, Route } from 'app/plugins/datasource/alertmanager/types';
|
import { Matcher, MatcherOperator, Route } from 'app/plugins/datasource/alertmanager/types';
|
||||||
import { Labels } from 'app/types/unified-alerting-dto';
|
import { Labels } from 'app/types/unified-alerting-dto';
|
||||||
import {
|
import { parseMatcher, parseMatchers, labelsMatchMatchers, removeMuteTimingFromRoute } from './alertmanager';
|
||||||
parseMatcher,
|
|
||||||
parseMatchers,
|
|
||||||
stringifyMatcher,
|
|
||||||
labelsMatchMatchers,
|
|
||||||
removeMuteTimingFromRoute,
|
|
||||||
} from './alertmanager';
|
|
||||||
|
|
||||||
describe('Alertmanager utils', () => {
|
describe('Alertmanager utils', () => {
|
||||||
describe('parseMatcher', () => {
|
describe('parseMatcher', () => {
|
||||||
@@ -61,19 +55,6 @@ describe('Alertmanager utils', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('stringifyMatcher', () => {
|
|
||||||
it('should stringify matcher correctly', () => {
|
|
||||||
expect(
|
|
||||||
stringifyMatcher({
|
|
||||||
name: 'foo',
|
|
||||||
value: 'boo="bar"',
|
|
||||||
isRegex: true,
|
|
||||||
isEqual: false,
|
|
||||||
})
|
|
||||||
).toEqual('foo!~"boo=\\"bar\\""');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('parseMatchers', () => {
|
describe('parseMatchers', () => {
|
||||||
it('should parse all operators', () => {
|
it('should parse all operators', () => {
|
||||||
expect(parseMatchers('foo=bar, bar=~ba.+, severity!=warning, email!~@grafana.com')).toEqual<Matcher[]>([
|
expect(parseMatchers('foo=bar, bar=~ba.+, severity!=warning, email!~@grafana.com')).toEqual<Matcher[]>([
|
||||||
|
|||||||
@@ -125,14 +125,6 @@ function unescapeMatcherValue(value: string) {
|
|||||||
return trimmed.replace(/\\"/g, '"');
|
return trimmed.replace(/\\"/g, '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeMatcherValue(value: string) {
|
|
||||||
return '"' + value.replace(/"/g, '\\"') + '"';
|
|
||||||
}
|
|
||||||
|
|
||||||
export function stringifyMatcher(matcher: Matcher): string {
|
|
||||||
return `${matcher.name}${matcherToOperator(matcher)}${escapeMatcherValue(matcher.value)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function parseMatcher(matcher: string): Matcher {
|
export function parseMatcher(matcher: string): Matcher {
|
||||||
const trimmed = matcher.trim();
|
const trimmed = matcher.trim();
|
||||||
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user