Documentation ¶
Index ¶
- func Assert(tb testing.TB, condition bool, v ...interface{})
- func Equals(tb testing.TB, exp, act interface{}, v ...interface{})
- func FaultOrPanicToErr(f func()) (err error)
- func GatherAndCompare(t *testing.T, g1, g2 prometheus.Gatherer, filter string)
- func NotOk(tb testing.TB, err error, v ...interface{})
- func Ok(tb testing.TB, err error, v ...interface{})
- func PutOutOfOrderIndex(blockDir string, minTime int64, maxTime int64) error
- func TolerantVerifyLeak(t *testing.T)
- func TolerantVerifyLeakMain(m *testing.M)
- type TB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FaultOrPanicToErr ¶ added in v0.26.0
func FaultOrPanicToErr(f func()) (err error)
FaultOrPanicToErr returns error if panic of fault was triggered during execution of function.
func GatherAndCompare ¶ added in v0.26.0
func GatherAndCompare(t *testing.T, g1, g2 prometheus.Gatherer, filter string)
GatherAndCompare compares the metrics of a Gatherers pair.
func PutOutOfOrderIndex ¶ added in v0.26.0
PutOutOfOrderIndex updates the index in blockDir with an index containing an out-of-order chunk copied from https://github.com/prometheus/prometheus/blob/b1ed4a0a663d0c62526312311c7529471abbc565/tsdb/index/index_test.go#L346
func TolerantVerifyLeak ¶ added in v0.26.0
TolerantVerifyLeak verifies go leaks but excludes the go routines that are launched as side effects of some of our dependencies.
func TolerantVerifyLeakMain ¶ added in v0.26.0
TolerantVerifyLeakMain verifies go leaks but excludes the go routines that are launched as side effects of some of our dependencies.
Types ¶
type TB ¶ added in v0.26.0
type TB interface { testing.TB IsBenchmark() bool Run(name string, f func(t TB)) bool SetBytes(n int64) N() int ResetTimer() }
TB represents union of test and benchmark. This allows the same test suite to be run by both benchmark and test, helping to reuse more code. The reason is that usually benchmarks are not being run on CI, especially for short tests, so you need to recreate usually similar tests for `Test<Name>(t *testing.T)` methods. Example of usage is presented here:
func TestTestOrBench(t *testing.T) { tb := NewTB(t) tb.Run("1", func(tb TB) { testorbenchComplexTest(tb) }) tb.Run("2", func(tb TB) { testorbenchComplexTest(tb) }) } func BenchmarkTestOrBench(b *testing.B) { tb := NewTB(t) tb.Run("1", func(tb TB) { testorbenchComplexTest(tb) }) tb.Run("2", func(tb TB) { testorbenchComplexTest(tb) }) }