add test for acquis
This commit is contained in:
parent
6b4674104c
commit
dab943fd7c
3 changed files with 54 additions and 0 deletions
47
pkg/acquisition/file_reader_test.go
Normal file
47
pkg/acquisition/file_reader_test.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
6
pkg/acquisition/tests/acquis.yaml
Normal file
6
pkg/acquisition/tests/acquis.yaml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
filenames:
|
||||||
|
- ./tests/test.log
|
||||||
|
labels:
|
||||||
|
type: my_test_log
|
||||||
|
---
|
||||||
|
|
1
pkg/acquisition/tests/test.log
Normal file
1
pkg/acquisition/tests/test.log
Normal file
|
@ -0,0 +1 @@
|
||||||
|
my test log
|
Loading…
Add table
Reference in a new issue