Alerting: remove dead code (#43956)

pull/44014/head
Gilles De Mey 3 years ago committed by GitHub
parent 274abf53ba
commit 55ec05b560
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      public/app/features/alerting/unified/utils/alertmanager.test.ts
  2. 8
      public/app/features/alerting/unified/utils/alertmanager.ts

@ -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[]>([

@ -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('}')) {

Loading…
Cancel
Save