Alerting: remove dead code (#43956)

This commit is contained in:
Gilles De Mey
2022-01-13 16:23:49 +01:00
committed by GitHub
parent 274abf53ba
commit 55ec05b560
2 changed files with 1 additions and 28 deletions

View File

@@ -1,12 +1,6 @@
import { Matcher, MatcherOperator, Route } from 'app/plugins/datasource/alertmanager/types';
import { Labels } from 'app/types/unified-alerting-dto';
import {
parseMatcher,
parseMatchers,
stringifyMatcher,
labelsMatchMatchers,
removeMuteTimingFromRoute,
} from './alertmanager';
import { parseMatcher, parseMatchers, labelsMatchMatchers, removeMuteTimingFromRoute } from './alertmanager';
describe('Alertmanager utils', () => {
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', () => {
it('should parse all operators', () => {
expect(parseMatchers('foo=bar, bar=~ba.+, severity!=warning, email!~@grafana.com')).toEqual<Matcher[]>([

View File

@@ -125,14 +125,6 @@ function unescapeMatcherValue(value: string) {
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 {
const trimmed = matcher.trim();
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {