tester

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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.

func (*Report) Empty

func (r *Report) Empty() bool

Empty reports if the report specifies no successful matches and no generated warning.

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.

Directories

Path Synopsis
Package tester provides an implementation of tester.Tester.
Package tester provides an implementation of tester.Tester.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL