mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 00:23:18 +00:00
Add rulefmt tests
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
This commit is contained in:
parent
5ad74e6e71
commit
8e500dbd39
@ -73,12 +73,21 @@ func TestParseFileFailure(t *testing.T) {
|
||||
filename: "invalid_label_name.bad.yaml",
|
||||
errMsg: "invalid label name",
|
||||
},
|
||||
{
|
||||
filename: "record_and_for.bad.yaml",
|
||||
errMsg: "invalid field 'for' in recording rule",
|
||||
},
|
||||
{
|
||||
filename: "record_and_keep_firing_for.bad.yaml",
|
||||
errMsg: "invalid field 'keep_firing_for' in recording rule",
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range table {
|
||||
_, errs := ParseFile(filepath.Join("testdata", c.filename))
|
||||
require.NotNil(t, errs, "Expected error parsing %s but got none", c.filename)
|
||||
require.Error(t, errs[0], c.errMsg, "Expected error for %s.", c.filename)
|
||||
require.Error(t, errs[0])
|
||||
require.Containsf(t, errs[0].Error(), c.errMsg, "Expected error for %s.", c.filename)
|
||||
}
|
||||
}
|
||||
|
||||
|
6
model/rulefmt/testdata/record_and_for.bad.yaml
vendored
Normal file
6
model/rulefmt/testdata/record_and_for.bad.yaml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
groups:
|
||||
- name: yolo
|
||||
rules:
|
||||
- record: Hello
|
||||
expr: 1
|
||||
for: 1m
|
6
model/rulefmt/testdata/record_and_keep_firing_for.bad.yaml
vendored
Normal file
6
model/rulefmt/testdata/record_and_keep_firing_for.bad.yaml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
groups:
|
||||
- name: yolo
|
||||
rules:
|
||||
- record: Hello
|
||||
expr: 1
|
||||
keep_firing_for: 1m
|
Loading…
Reference in New Issue
Block a user