|
| 1 | +package checks_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/cloudflare/pint/internal/checks" |
| 7 | + "github.com/cloudflare/pint/internal/parser" |
| 8 | + "github.com/cloudflare/pint/internal/promapi" |
| 9 | +) |
| 10 | + |
| 11 | +func TestReportCheck(t *testing.T) { |
| 12 | + testCases := []checkTest{ |
| 13 | + { |
| 14 | + description: "report passed problem / warning", |
| 15 | + content: "- alert: foo\n expr: sum(foo)\n annotations:\n alert: foo\n", |
| 16 | + checker: func(_ *promapi.FailoverGroup) checks.RuleChecker { |
| 17 | + return checks.NewReportCheck("problem reported", checks.Warning) |
| 18 | + }, |
| 19 | + prometheus: noProm, |
| 20 | + problems: func(_ string) []checks.Problem { |
| 21 | + return []checks.Problem{ |
| 22 | + { |
| 23 | + Lines: parser.LineRange{ |
| 24 | + First: 1, |
| 25 | + Last: 4, |
| 26 | + }, |
| 27 | + Reporter: "rule/report", |
| 28 | + Text: "problem reported", |
| 29 | + Severity: checks.Warning, |
| 30 | + }, |
| 31 | + } |
| 32 | + }, |
| 33 | + }, |
| 34 | + { |
| 35 | + description: "report passed problem / info", |
| 36 | + content: "- record: foo\n expr: sum(foo)\n", |
| 37 | + checker: func(_ *promapi.FailoverGroup) checks.RuleChecker { |
| 38 | + return checks.NewReportCheck("problem reported", checks.Information) |
| 39 | + }, |
| 40 | + prometheus: noProm, |
| 41 | + problems: func(_ string) []checks.Problem { |
| 42 | + return []checks.Problem{ |
| 43 | + { |
| 44 | + Lines: parser.LineRange{ |
| 45 | + First: 1, |
| 46 | + Last: 2, |
| 47 | + }, |
| 48 | + Reporter: "rule/report", |
| 49 | + Text: "problem reported", |
| 50 | + Severity: checks.Information, |
| 51 | + }, |
| 52 | + } |
| 53 | + }, |
| 54 | + }, |
| 55 | + } |
| 56 | + runTests(t, testCases) |
| 57 | +} |
0 commit comments