asserter

package
v3.32.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EntityMetricIs

func EntityMetricIs(e *integration.Entity, metricName string, metricValue interface{}) bool

EntityMetricIs returns true if the specified entity has a metric named metricName equal to metricValue.

func EntityMetricTypeIs

func EntityMetricTypeIs(e *integration.Entity, metricName string, metricType metric.SourceType) bool

EntityMetricTypeIs returns true if supplied entity has metric named metricName with type _similar_ to metricType.

Types

type Asserter

type Asserter struct {
	// contains filtered or unexported fields
}

Asserter is a helper for checking whether an integration contains all the metrics defined in a specGroup. It provides a chainable API, with each call returning a copy of the asserter. This way, successive calls to the chainable methods do not modify the previous Asserter, allowing to reuse the chain as a test fans out. Asserter is safe to use concurrently.

func New

func New() Asserter

New returns an empty asserter.

func (Asserter) AliasingGroups added in v3.6.0

func (a Asserter) AliasingGroups(aliases map[string]string) Asserter

AliasingGroups returns an asserter configured with an alias for groups so it is possible to look for entities with a different group name.

func (Asserter) Assert

func (a Asserter) Assert(t *testing.T)

Assert checks whether all metrics defined in the supplied groups are present, and fails the test if any is not. Assert will fail the test if:

  • No entity at all exists with a type matching a specGroup, unless this specGroup is ignored using ExcludingGroups.
  • Any entity whose type matches a specGroup lacks any metric defined in the specGroup, unless any Func returns true for that particular groupName, metric, and entity.

func (Asserter) Excluding

func (a Asserter) Excluding(excludeFuncs ...exclude.Func) Asserter

Excluding returns an asserter that will not fail for a missing metric for which any of the supplied Func return true. For ignoring whole spec groups, use ExcludingGroups instead. Missing metrics are still logged, unless Silently is used.

func (Asserter) ExcludingGroups

func (a Asserter) ExcludingGroups(groupNames ...string) Asserter

ExcludingGroups returns an asserter configured to completely exclude the supplied groups. Unlike Excluding, ExcludingGroups will ignore the group _before_ checking if there are any entities at all matching the group, an scenario that would make the asserter fail if the group is not excluded this way.

func (Asserter) On

func (a Asserter) On(entities []*integration.Entity) Asserter

On returns an asserter configured to check for existence on the supplied entities.

func (Asserter) Silently

func (a Asserter) Silently() Asserter

Silently returns an asserter that will not log optional or excepted metrics

func (Asserter) Using

func (a Asserter) Using(groups definition.SpecGroups) Asserter

Using returns an asserter that will use the supplied specGroups to assert entities.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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