mirror of
https://github.com/prymitive/karma
synced 2026-08-23 11:56:20 +00:00
fix(backend): add missing tests and fix strip code
This commit is contained in:
committed by
Łukasz Mierzwa
parent
df64dbc33d
commit
c486bc7308
@@ -0,0 +1,14 @@
|
||||
karma.bin-should-fail --config.file=karma.yaml
|
||||
! stdout .
|
||||
cmp stderr stderr.txt
|
||||
|
||||
-- stderr.txt --
|
||||
level=error msg="Execution failed" error="keep regex rule 'foo.++++' is invalid: error parsing regexp: invalid nested repetition operator: `++`"
|
||||
-- karma.yaml --
|
||||
alertmanager:
|
||||
servers:
|
||||
- name: default
|
||||
uri: https://127.0.0.1:9093
|
||||
receivers:
|
||||
keep_re:
|
||||
- foo.++++
|
||||
@@ -0,0 +1,14 @@
|
||||
karma.bin-should-fail --config.file=karma.yaml
|
||||
! stdout .
|
||||
cmp stderr stderr.txt
|
||||
|
||||
-- stderr.txt --
|
||||
level=error msg="Execution failed" error="strip regex rule 'foo.++++' is invalid: error parsing regexp: invalid nested repetition operator: `++`"
|
||||
-- karma.yaml --
|
||||
alertmanager:
|
||||
servers:
|
||||
- name: default
|
||||
uri: https://127.0.0.1:9093
|
||||
receivers:
|
||||
strip_re:
|
||||
- foo.++++
|
||||
@@ -426,7 +426,7 @@ func (config *configSchema) Read(flags *pflag.FlagSet) (string, error) {
|
||||
}
|
||||
|
||||
config.Receivers.CompiledStripRegex = make([]*regexp.Regexp, len(config.Receivers.StripRegex))
|
||||
for i, stripRegex := range config.Receivers.KeepRegex {
|
||||
for i, stripRegex := range config.Receivers.StripRegex {
|
||||
config.Receivers.CompiledStripRegex[i], err = regex.CompileAnchored(stripRegex)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("strip regex rule '%s' is invalid: %w", stripRegex, err)
|
||||
|
||||
Reference in New Issue
Block a user