Documentation
¶
Overview ¶
Package tester provides the definition of test Tester, tester Report and ReportEncoder. A Tester allows to verify that the running tests produce the expected outcomes. A Tester produces a Report for a given test. A ReportEncoder can be used to encode and write the report to some destination.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Report ¶
type Report struct {
TestName string `json:"test" yaml:"test"`
RuleName string `json:"-" yaml:"-"`
OriginatingTestCase map[string]any `json:"originatingTestCase,omitempty" yaml:"originatingTestCase,omitempty"`
SuccessfulMatches int `json:"successfulMatches" yaml:"successfulMatches"`
GeneratedWarnings []ReportWarning `json:"generatedWarnings,omitempty" yaml:"generatedWarnings,omitempty"`
}
A Report contains information regarding the successful matches and generated warning for given test testing a given rule.
type ReportFieldWarning ¶
type ReportFieldWarning struct {
Field string `json:"field" yaml:"field"`
Expected any `json:"expected" yaml:"expected"`
Got any `json:"got" yaml:"got"`
}
ReportFieldWarning contains information regarding an expected outcome field, its expected value and the value contained in the alert.
type ReportWarning ¶
type ReportWarning struct {
FieldWarnings []ReportFieldWarning `json:"fieldWarnings,omitempty" yaml:"fieldWarnings,omitempty"`
}
A ReportWarning is associated to a received alert matching a rule, but having some fields not matching the expected outcome definition.
type Tester ¶
type Tester interface {
// StartAlertsCollection starts the process of alerts collection.
StartAlertsCollection(ctx context.Context) error
// Report returns a report containing information regarding the alerts matching or not matching the provided
// expected outcome for the provided rule. A nil or empty expected outcome matches any alert corresponding to the
// provided rule.
// Notice: the Tester doesn't populate the returned Report.TestName, Report.RuleName and Report.OriginatingTestCase
// fields, so it is a user duty to fill them if needed.
Report(uid *uuid.UUID, rule string, expectedOutcome *loader.TestExpectedOutcome) *Report
}
Tester allows to verify that the running tests produce the expected outcomes.