mock

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatal

func Fatal(tb testing.TB) testing.TB

Fatal is a wrapper around *testing.T and *testing.B that causes Sink Assert* methods to immediately fail a test and stop execution. Otherwise, the Assert methods call tb.Errorf(), which marks the test as failed, but allows execution to continue.

Examples of Fatal() can be found in the sink test code.

var sink Sink
var t *testing.T
sink.AssertCounterEquals(Must(t), "name", 1)

Types

type Sink

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

A Sink is a mock sink meant for testing that is safe for concurrent use.

func NewSink

func NewSink() *Sink

NewSink returns a new Sink which implements the stats.Sink interface and is suitable for testing.

func (*Sink) AssertCounterCallCount

func (s *Sink) AssertCounterCallCount(tb testing.TB, name string, exp int)

AssertCounterCallCount asserts that Counter name was called exp times.

func (*Sink) AssertCounterEquals

func (s *Sink) AssertCounterEquals(tb testing.TB, name string, exp uint64)

AssertCounterEquals asserts that Counter name is present and has value exp.

func (*Sink) AssertCounterExists

func (s *Sink) AssertCounterExists(tb testing.TB, name string)

AssertCounterExists asserts that Counter name exists.

func (*Sink) AssertCounterNotExists

func (s *Sink) AssertCounterNotExists(tb testing.TB, name string)

AssertCounterNotExists asserts that Counter name does not exist.

func (*Sink) AssertGaugeCallCount

func (s *Sink) AssertGaugeCallCount(tb testing.TB, name string, exp int)

AssertGaugeCallCount asserts that Gauge name was called exp times.

func (*Sink) AssertGaugeEquals

func (s *Sink) AssertGaugeEquals(tb testing.TB, name string, exp uint64)

AssertGaugeEquals asserts that Gauge name is present and has value exp.

func (*Sink) AssertGaugeExists

func (s *Sink) AssertGaugeExists(tb testing.TB, name string)

AssertGaugeExists asserts that Gauge name exists.

func (*Sink) AssertGaugeNotExists

func (s *Sink) AssertGaugeNotExists(tb testing.TB, name string)

AssertGaugeNotExists asserts that Gauge name does not exist.

func (*Sink) AssertTimerCallCount

func (s *Sink) AssertTimerCallCount(tb testing.TB, name string, exp int)

AssertTimerCallCount asserts that Timer name was called exp times.

func (*Sink) AssertTimerEquals

func (s *Sink) AssertTimerEquals(tb testing.TB, name string, exp float64)

AssertTimerEquals asserts that Timer name is present and has value exp.

func (*Sink) AssertTimerExists

func (s *Sink) AssertTimerExists(tb testing.TB, name string)

AssertTimerExists asserts that Timer name exists.

func (*Sink) AssertTimerNotExists

func (s *Sink) AssertTimerNotExists(tb testing.TB, name string)

AssertTimerNotExists asserts that Timer name does not exist.

func (*Sink) Counter

func (s *Sink) Counter(name string) uint64

Counter is shorthand for LoadCounter, zero is returned if the stat is not found.

func (*Sink) CounterCallCount

func (s *Sink) CounterCallCount(name string) int64

CounterCallCount returns the number of times stat name has been called/updated.

func (*Sink) Counters added in v0.4.2

func (s *Sink) Counters() map[string]uint64

Counters returns all the counters currently stored by the sink.

func (*Sink) Flush

func (*Sink) Flush()

Flush is a no-op method

func (*Sink) FlushCounter

func (s *Sink) FlushCounter(name string, val uint64)

FlushCounter implements the stats.Sink.FlushCounter method and adds val to stat name.

func (*Sink) FlushGauge

func (s *Sink) FlushGauge(name string, val uint64)

FlushGauge implements the stats.Sink.FlushGauge method and adds val to stat name.

func (*Sink) FlushTimer

func (s *Sink) FlushTimer(name string, val float64)

FlushTimer implements the stats.Sink.FlushTimer method and adds val to stat name.

func (*Sink) Gauge

func (s *Sink) Gauge(name string) uint64

Gauge is shorthand for LoadGauge, zero is returned if the stat is not found.

func (*Sink) GaugeCallCount

func (s *Sink) GaugeCallCount(name string) int64

GaugeCallCount returns the number of times stat name has been called/updated.

func (*Sink) Gauges added in v0.4.2

func (s *Sink) Gauges() map[string]uint64

Gauges returns all the gauges currently stored by the sink.

func (*Sink) LoadCounter

func (s *Sink) LoadCounter(name string) (uint64, bool)

LoadCounter returns the value for stat name and if it was found.

func (*Sink) LoadGauge

func (s *Sink) LoadGauge(name string) (uint64, bool)

LoadGauge returns the value for stat name and if it was found.

func (*Sink) LoadTimer

func (s *Sink) LoadTimer(name string) (float64, bool)

LoadTimer returns the value for stat name and if it was found.

func (*Sink) Reset

func (s *Sink) Reset()

Reset resets the Sink's counters, timers and gauges to zero.

func (*Sink) Timer

func (s *Sink) Timer(name string) float64

Timer is shorthand for LoadTimer, zero is returned if the stat is not found.

func (*Sink) TimerCallCount

func (s *Sink) TimerCallCount(name string) int64

TimerCallCount returns the number of times stat name has been called/updated.

func (*Sink) Timers added in v0.4.2

func (s *Sink) Timers() map[string]float64

Timers returns all the timers currently stored by the sink.

Jump to

Keyboard shortcuts

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