fixtures

package
v0.0.0-...-06760cc Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

This is for test fixtures only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropSource

func DropSource(m *gostatsd.Metric)

func EnsureAttachedTimers

func EnsureAttachedTimers(tb testing.TB, clck *clock.Mock, expect int, until time.Duration) bool

EnsureAttachedTimers will block execution until either expected number of timers are reached or the until duration has been reached causing this method to fail the test. A true result is returned when the assertion passes allow for control flow of control, otherwise the assertional failed and should ensure the test fails gracefully.

func MakeMetric

func MakeMetric(opts ...MetricOpt) *gostatsd.Metric

MakeMetric provides a way to build a metric for tests. Hopefully over time this will be used more, bringing more consistency to tests.

func NewAdvancingClock

func NewAdvancingClock(ctx context.Context) (context.Context, func())

NewAdvancingClock attaches a virtual clock to a context which advances at full speed (not wall speed), and a cancel function to stop it. The clock also stops if the context is canceled.

func NextStep

func NextStep(ctx context.Context, clck *clock.Mock)

NextStep will advance the supplied clock.Mock until it moves, or the context.Context is canceled (which typically means it timed out in wall-time). This is useful when testing things that exist inside goroutines, when it's not possible to tell when the goroutine is ready to consume mock time.

func SortCompare

func SortCompare(ms []*gostatsd.Metric) func(i, j int) bool

SortCompare func for metrics so they can be compared with require.EqualValues Invoke with sort.Slice(x, SortCompare(x))

Types

type MetricOpt

type MetricOpt func(m *gostatsd.Metric)

func AddTag

func AddTag(t ...string) MetricOpt

func DropTag

func DropTag(t string) MetricOpt

func Name

func Name(n string) MetricOpt

type MockNodePicker

type MockNodePicker struct {
	TB testing.TB

	FnAdd    func(node string)
	FnList   func() []string
	FnRemove func(node string)
	FnRun    func(ctx context.Context)
	FnSelect func(key string) (string, bool, error)
}

MockNodePicker implements a mock nodes.NodePicker from github.com/atlassian/gostatsd/internal/cluster/nodes

func (*MockNodePicker) Add

func (m *MockNodePicker) Add(node string)

func (*MockNodePicker) List

func (m *MockNodePicker) List() (p0 []string)

func (*MockNodePicker) Remove

func (m *MockNodePicker) Remove(node string)

func (*MockNodePicker) Run

func (m *MockNodePicker) Run(ctx context.Context)

func (*MockNodePicker) Select

func (m *MockNodePicker) Select(key string) (p0 string, p1 bool, p2 error)

Jump to

Keyboard shortcuts

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