touchtest

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package touchtest exposes common prometheus testing utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertions

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

Assertions is a set of test verifications for metrics. Principally, this involves comparisons against an expected Gatherer.

func New

func New(t require.TestingT) *Assertions

New creates an Assertions for the given testing environment.

func NewSuite

func NewSuite(s suite.TestingSuite) *Assertions

NewSuite creates an Assertions for the given testing suite.

func (*Assertions) CollectAndCompare

func (a *Assertions) CollectAndCompare(actual prometheus.Collector, metricNames ...string) bool

CollectAndCompare compares the actual collector against the current expectation previously set with Expect. This method fails the test on any error, then returns false. This method returns true if the expectation was met.

Use this method to run an assertion against a single metric that optionally has multiple submetrics.

func (*Assertions) Expect

func (a *Assertions) Expect(g prometheus.Gatherer) *Assertions

Expect loads a given set of metrics into this set of assertions. Multiple assertions can be made against this expected set without reencoding.

If any errors occur while encoding the given expected Gatherer, the enclosing test is failed.

func (*Assertions) GatherAndCompare

func (a *Assertions) GatherAndCompare(actual prometheus.Gatherer, metricNames ...string) bool

GatherAndCompare compares the actual Gatherer against the current expectation previously set with Expect. This method fails the test on any error, then returns false. This method returns true if the expectation was met.

Use this method to run an assertion against an entire prometheus registry.

func (*Assertions) NotRegistered

func (a *Assertions) NotRegistered(metricNames ...string) bool

NotRegistered asserts that the given metric names are absent in the current expectation previously set with Expect.

func (*Assertions) Registered

func (a *Assertions) Registered(metricNames ...string) bool

Registered asserts that the given metric names are present in the current expectation previously set with Expect.

Jump to

Keyboard shortcuts

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