utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricsTestCase

type MetricsTestCase struct {
	// Target is the Prometheus Collector implementation to test
	Target prometheus.Collector
	// Want is the expected output in the metric API response as the result of Target Collector
	Want string
	// Metrics is the names of the metrics to test; leave empty to test all metrics.
	Metrics []string
}

MetricsTestCase can be used to unit test a Prometheus Collector implementation. It takes a initialized Prometheus Collector and check if the metric it defines is standard and produces the expected output.

func (MetricsTestCase) Test

func (mtc MetricsTestCase) Test() ([]promlint.Problem, error)

Test runs the tests. It returns an error if the Collector does not work properly. It returns a list of link errors and no errors if the Collector works but has non-standard definition.

type MetricsTestCases

type MetricsTestCases map[string]MetricsTestCase

MetricsTestCases is a alias for a set of MetricsTestCase. It provide a convenient and standard way to unit test multiple MetricsTestCase. The keys of the map are the names of the test cases.

func (MetricsTestCases) Test

func (mtc MetricsTestCases) Test(t *testing.T)

Test runs all given test cases under the given testing.T object.

Jump to

Keyboard shortcuts

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