-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogparse_test.go
More file actions
32 lines (26 loc) · 949 Bytes
/
logparse_test.go
File metadata and controls
32 lines (26 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package zeekparse
import (
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"testing"
)
func basicCheckofParse(t *testing.T, results []ZeekLogEntry, entryCountExpected, fieldCountExpected int) {
assert.True(t, len(results) == entryCountExpected)
for _, thisResult := range results {
assert.Equal(t, len(thisResult), fieldCountExpected)
}
}
func TestParseZeekLog(t *testing.T) {
log.SetLevel(log.InfoLevel)
const numEntriesInLog = 3
const fieldsInLog = 24
// uncompressed case
uncompressedResults, header, uncompErr := parseZeekLog("test_input/simple_dns.log")
basicCheckofParse(t, uncompressedResults, numEntriesInLog, fieldsInLog)
assert.True(t, len(header.setSeparator) > 0)
assert.NoError(t, uncompErr)
// compressed case
compressedResults, _, compErr := parseZeekLog("test_input/simple_dns.log.gz")
basicCheckofParse(t, compressedResults, numEntriesInLog, fieldsInLog)
assert.NoError(t, compErr)
}