Documentation
¶
Index ¶
- func AddOptions(opts ...Option)
- func SetOptions(opts ...Option)
- type Assert
- func (a Assert) Sum(expected IntOrFloat, msgAndArgs ...any) bool
- func (a Assert) SumGreater(expected IntOrFloat, msgAndArgs ...any) bool
- func (a Assert) SumGreaterOrEqual(expected IntOrFloat, msgAndArgs ...any) bool
- func (a Assert) SumLess(expected IntOrFloat, msgAndArgs ...any) bool
- func (a Assert) SumLessOrEqual(expected IntOrFloat, msgAndArgs ...any) bool
- func (a Assert) Value(expected IntOrFloat, msgAndArgs ...any) bool
- func (a Assert) ValueGreater(expected IntOrFloat, msgAndArgs ...any) bool
- func (a Assert) ValueGreaterOrEqual(expected IntOrFloat, msgAndArgs ...any) bool
- func (a Assert) ValueLess(expected IntOrFloat, msgAndArgs ...any) bool
- func (a Assert) ValueLessOrEqual(expected IntOrFloat, msgAndArgs ...any) bool
- type AssertGroup
- type Group
- func (g Group[K]) Aggregate(fn genq.AggregationFunc[float64]) map[K]metrq.Metric
- func (g Group[K]) AggregateFlat(fn genq.AggregationFunc[float64]) metrq.Metrics
- func (g Group[K]) Assert() AssertGroup[K]
- func (g Group[K]) Float(fn genq.AggregationFunc[float64]) map[K]float64
- func (g Group[K]) FloatSum() map[K]float64
- func (g Group[K]) Int(fn genq.AggregationFunc[float64]) map[K]int64
- func (g Group[K]) IntSum() map[K]int64
- func (g Group[K]) Require() RequireGroup[K]
- type IntOrFloat
- type MetrT
- func (t MetrT) Collect(filters ...metrq.FilterFunc) Metrics
- func (t MetrT) Finish() Metrics
- func (t MetrT) Scope(fn func(mt MetrT)) Metrics
- func (t MetrT) Snapshot() Metrics
- func (t MetrT) Start() MetrT
- func (t MetrT) T() *testing.T
- func (t MetrT) WithCollectFilter(filter ...metrq.FilterFunc) MetrT
- func (t MetrT) WithOptions(opts ...Option) MetrT
- func (t MetrT) WithSnapshot(metrics metrq.Metrics) MetrT
- func (t MetrT) WithT(tt *testing.T) MetrT
- func (t MetrT) WithoutSnapshot() MetrT
- type Metrics
- func (f Metrics) And(operands ...genq.FilterFunc[metrq.Metric]) Metrics
- func (f Metrics) Assert() Assert
- func (f Metrics) Group(fn genq.GroupFunc[string, metrq.Metric]) Group[string]
- func (f Metrics) Metrics() metrq.Metrics
- func (f Metrics) Or(operands ...genq.FilterFunc[metrq.Metric]) Metrics
- func (f Metrics) Require() Require
- func (f Metrics) Resolve() []metrq.Metric
- func (f Metrics) Where(operands ...genq.FilterFunc[metrq.Metric]) Metrics
- type Option
- type Require
- func (r Require) Sum(expected IntOrFloat, msgAndArgs ...any)
- func (r Require) SumGreater(expected IntOrFloat, msgAndArgs ...any)
- func (r Require) SumGreaterOrEqual(expected IntOrFloat, msgAndArgs ...any)
- func (r Require) SumLess(expected IntOrFloat, msgAndArgs ...any)
- func (r Require) SumLessOrEqual(expected IntOrFloat, msgAndArgs ...any)
- func (r Require) Value(expected IntOrFloat, msgAndArgs ...any)
- func (r Require) ValueGreater(expected IntOrFloat, msgAndArgs ...any)
- func (r Require) ValueGreaterOrEqual(expected IntOrFloat, msgAndArgs ...any)
- func (r Require) ValueLess(expected IntOrFloat, msgAndArgs ...any)
- func (r Require) ValueLessOrEqual(expected IntOrFloat, msgAndArgs ...any)
- type RequireGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddOptions ¶
func AddOptions(opts ...Option)
func SetOptions ¶
func SetOptions(opts ...Option)
Types ¶
type Assert ¶
type Assert struct {
// contains filtered or unexported fields
}
func (Assert) SumGreater ¶
func (a Assert) SumGreater(expected IntOrFloat, msgAndArgs ...any) bool
func (Assert) SumGreaterOrEqual ¶
func (a Assert) SumGreaterOrEqual(expected IntOrFloat, msgAndArgs ...any) bool
func (Assert) SumLessOrEqual ¶
func (a Assert) SumLessOrEqual(expected IntOrFloat, msgAndArgs ...any) bool
func (Assert) ValueGreater ¶
func (a Assert) ValueGreater(expected IntOrFloat, msgAndArgs ...any) bool
func (Assert) ValueGreaterOrEqual ¶
func (a Assert) ValueGreaterOrEqual(expected IntOrFloat, msgAndArgs ...any) bool
func (Assert) ValueLessOrEqual ¶
func (a Assert) ValueLessOrEqual(expected IntOrFloat, msgAndArgs ...any) bool
type AssertGroup ¶
type AssertGroup[K comparable] struct { // contains filtered or unexported fields }
func (AssertGroup[K]) Sum ¶
func (a AssertGroup[K]) Sum(expected map[K]int64) bool
type Group ¶
type Group[K comparable] struct { T MetrT `chaingen:"-"` // contains filtered or unexported fields }
func (Group[K]) AggregateFlat ¶
func (Group[K]) Assert ¶
func (g Group[K]) Assert() AssertGroup[K]
func (Group[K]) Require ¶
func (g Group[K]) Require() RequireGroup[K]
type IntOrFloat ¶
type IntOrFloat any
type MetrT ¶
type MetrT struct {
// contains filtered or unexported fields
}
MetrT stands for Metrics Testing. In your test code, use `mt` variable name for it of a `MetrT` type (no pointer!). All modifier functions of MetrT return a new copy of MetrT, making it thread safe, and easy to reuse. If you want to persist changes, reassign the result of modifier function back to the variable. Example: mt = mt.WithCollectFilter(mcqold.Prefix("my_awesome_app")).Start() You can store and access multiple copies of MetrT, which will contain their own snapshots, so you can mix and match different sets of metrics.
func (MetrT) Collect ¶
func (t MetrT) Collect(filters ...metrq.FilterFunc) Metrics
Collect collects all metrics from the collector. If collection filter is set, it will ignore metrics that don't match the filter.
func (MetrT) Finish ¶
Finish returns difference between metrics snapshot and newly collected metrics.
func (MetrT) Scope ¶
Scope runs provided function, and returns metrics changes that happened during its execution. This is a shorthand for: mt = mt.Start() .. do something delta := mt.Finish()
func (MetrT) WithCollectFilter ¶
func (t MetrT) WithCollectFilter(filter ...metrq.FilterFunc) MetrT
WithCollectFilter sets collector filter, which affects which metrics are visible to MetrT.
func (MetrT) WithOptions ¶
WithOptions sets new options to MetrT.
func (MetrT) WithSnapshot ¶
WithSnapshot sets new snapshot to MetricsT
func (MetrT) WithoutSnapshot ¶
WithoutSnapshot sets empty snapshot.
type Metrics ¶
type Metrics struct { T MetrT `chaingen:"-"` // contains filtered or unexported fields }
type Option ¶
type Option func(o *options)
func WithCollectFilter ¶
func WithCollectFilter(fn ...metrq.FilterFunc) Option
WithCollectFilter sets collector filter, which affects which metrics are visible toe MetrT.
func WithCollector ¶
func WithCollector(collector metrcollect.Collector) Option
WithCollector sets a collector for MetrT. Collector is required for MetrT to function.
type Require ¶
type Require struct {
// contains filtered or unexported fields
}
func (Require) Sum ¶
func (r Require) Sum(expected IntOrFloat, msgAndArgs ...any)
func (Require) SumGreater ¶
func (r Require) SumGreater(expected IntOrFloat, msgAndArgs ...any)
func (Require) SumGreaterOrEqual ¶
func (r Require) SumGreaterOrEqual(expected IntOrFloat, msgAndArgs ...any)
func (Require) SumLess ¶
func (r Require) SumLess(expected IntOrFloat, msgAndArgs ...any)
func (Require) SumLessOrEqual ¶
func (r Require) SumLessOrEqual(expected IntOrFloat, msgAndArgs ...any)
func (Require) Value ¶
func (r Require) Value(expected IntOrFloat, msgAndArgs ...any)
func (Require) ValueGreater ¶
func (r Require) ValueGreater(expected IntOrFloat, msgAndArgs ...any)
func (Require) ValueGreaterOrEqual ¶
func (r Require) ValueGreaterOrEqual(expected IntOrFloat, msgAndArgs ...any)
func (Require) ValueLess ¶
func (r Require) ValueLess(expected IntOrFloat, msgAndArgs ...any)
func (Require) ValueLessOrEqual ¶
func (r Require) ValueLessOrEqual(expected IntOrFloat, msgAndArgs ...any)
type RequireGroup ¶
type RequireGroup[K comparable] struct { // contains filtered or unexported fields }
func (RequireGroup[K]) Sum ¶
func (r RequireGroup[K]) Sum(expected map[K]int64)