Documentation ¶
Index ¶
- func EqualTimestamp(t *testing.T, expect, actual time.Time, msgAndArgs ...interface{})
- func JSON() jsoniter.API
- func RunTests(t *testing.T, tests ...TestCase)
- func RunTestsFromYAML(t *testing.T, resolve logtypes.Finder, filename string)
- func TestRegisteredParser(t *testing.T, resolve logtypes.Finder, logType, input string, expect ...string)
- func TestResult(t *testing.T, expect string, actual *pantherlog.Result, ...)
- type TestCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualTimestamp ¶
EqualTimestamp is a helper that checks timestamps for equality with human readable message
func JSON ¶
JSON returns a jsoniter.API to be used for parser tests. The returned API forces omitempty to all fields and relies on global tcodec registration. It does not include conversion of output timestamp formats to make it easier to write test cases.
func RunTestsFromYAML ¶
RunTestsFromYAML reads all test cases in a YAML file and runs them.
func TestRegisteredParser ¶
func TestRegisteredParser(t *testing.T, resolve logtypes.Finder, logType, input string, expect ...string)
TestRegisteredParser is a helper to run a test for a registered log parser
func TestResult ¶
func TestResult(t *testing.T, expect string, actual *pantherlog.Result, indicators ...pantherlog.FieldID)
Checks that `actual` is a parser result matching `expect` If expect.RowID is empty it checks if actual has non-empty RowID If expect.EventTime is zero it checks if actual.EventTime equals actual.ParseTime If expect.ParseTime is zero it checks if actual.ParseTime is non-zero Otherwise equality is checked strictly
Types ¶
type TestCase ¶
type TestCase struct { Name string `json:"name" yaml:"name"` Input string `json:"input" yaml:"input"` Result string `json:"result" yaml:"result"` Results []string `json:"results" yaml:"results"` LogType string `json:"logType" yaml:"logType"` Resolve logtypes.Finder `json:"-" yaml:"-"` }
TestCase is a test case validating the input and output for a parser TODO: add fields to allow test cases to test that a parser produces errors