add test for acquis

This commit is contained in:
AlteredCoder 2020-07-22 14:08:21 +02:00
parent 6b4674104c
commit dab943fd7c
3 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1,47 @@
package acquisition
import (
"fmt"
"testing"
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
"gotest.tools/assert"
)
func TestLoadAcquisitionConfig(t *testing.T) {
tests := []struct {
csConfig *csconfig.CrowdSec
result *FileAcquisCtx
err error
}{
{
csConfig: &csconfig.CrowdSec{
SingleFile: "./tests/test.log",
SingleFileLabel: "my_test_log",
Profiling: false,
},
result: &FileAcquisCtx{
Files: []FileCtx{
{
Type: "file",
Mode: "cat",
Filename: "./tests/test.log",
Labels: map[string]string{
"type": "my_test_log",
},
Profiling: false,
},
},
},
err: nil,
},
}
for _, test := range tests {
result, err := LoadAcquisitionConfig(test.csConfig)
fmt.Printf("result : %+v\n", result)
fmt.Printf("test : %+v \n", test.result)
assert.Equal(t, test.result, result)
assert.Equal(t, test.err, err)
}
}

View file

@ -0,0 +1,6 @@
filenames:
- ./tests/test.log
labels:
type: my_test_log
---

View file

@ -0,0 +1 @@
my test log