mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 20:36:12 +02:00
refact parser Init: argument types (#3578)
* refact parser Init: argument types * lint * tests * rename struct field; drop redundant nil check
This commit is contained in:
parent
7c4e91d304
commit
d46cef1bcb
4 changed files with 27 additions and 33 deletions
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func TestParserConfigs(t *testing.T) {
|
||||
pctx, err := Init(map[string]interface{}{"patterns": "../../config/patterns/", "data": "./tests/"})
|
||||
pctx, err := NewUnixParserCtx("../../config/patterns/", "./tests/")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to load patterns : %s", err)
|
||||
}
|
||||
|
@ -47,11 +47,13 @@ func TestParserConfigs(t *testing.T) {
|
|||
{Key: string("MYGROKBIS"), Value: string("[a-z]")},
|
||||
}, Grok: GrokPattern{RegexpValue: "^x%{MYGROKBIS:extr}$", TargetField: "t"}}, false, true},
|
||||
}
|
||||
|
||||
for idx := range CfgTests {
|
||||
err := CfgTests[idx].NodeCfg.compile(pctx, EnricherCtx{})
|
||||
if CfgTests[idx].Compiles && err != nil {
|
||||
t.Fatalf("Compile: (%d/%d) expected valid, got : %s", idx+1, len(CfgTests), err)
|
||||
}
|
||||
|
||||
if !CfgTests[idx].Compiles && err == nil {
|
||||
t.Fatalf("Compile: (%d/%d) expected error", idx+1, len(CfgTests))
|
||||
}
|
||||
|
@ -60,6 +62,7 @@ func TestParserConfigs(t *testing.T) {
|
|||
if CfgTests[idx].Valid && err != nil {
|
||||
t.Fatalf("Valid: (%d/%d) expected valid, got : %s", idx+1, len(CfgTests), err)
|
||||
}
|
||||
|
||||
if !CfgTests[idx].Valid && err == nil {
|
||||
t.Fatalf("Valid: (%d/%d) expected error", idx+1, len(CfgTests))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue