Documentation ¶
Index ¶
- func AnythingBut(expected interface{}) interface{}
- func AssertFloatInRange(min float64, max float64) interface{}
- func IsGreaterOrEqual(expectedMin float64) interface{}
- func MatchEventLike(expected metrics.Event, allowedDelta time.Duration) interface{}
- func MatchTagsContains(expected []string) interface{}
- type MockSender
- func (m *MockSender) AssertEvent(t *testing.T, expectedEvent metrics.Event, allowedDelta time.Duration) bool
- func (m *MockSender) AssertEventMissing(t *testing.T, expectedEvent metrics.Event, allowedDelta time.Duration) bool
- func (m *MockSender) AssertHistogramBucket(t *testing.T, method string, metric string, value int, lowerBound float64, ...) bool
- func (m *MockSender) AssertMetric(t *testing.T, method string, metric string, value float64, hostname string, ...) bool
- func (m *MockSender) AssertMetricInRange(t *testing.T, method string, metric string, min float64, max float64, ...) bool
- func (m *MockSender) AssertMetricNotTaggedWith(t *testing.T, method string, metric string, tags []string) bool
- func (m *MockSender) AssertMetricTaggedWith(t *testing.T, method string, metric string, tags []string) bool
- func (m *MockSender) AssertServiceCheck(t *testing.T, checkName string, status metrics.ServiceCheckStatus, ...) bool
- func (m *MockSender) Commit()
- func (m *MockSender) Count(metric string, value float64, hostname string, tags []string)
- func (m *MockSender) Counter(metric string, value float64, hostname string, tags []string)
- func (m *MockSender) DisableDefaultHostname(d bool)
- func (m *MockSender) Event(e metrics.Event)
- func (m *MockSender) Gauge(metric string, value float64, hostname string, tags []string)
- func (m *MockSender) GetMetricStats() map[string]int64
- func (m *MockSender) Histogram(metric string, value float64, hostname string, tags []string)
- func (m *MockSender) HistogramBucket(metric string, value int, lowerBound, upperBound float64, monotonic bool, ...)
- func (m *MockSender) Historate(metric string, value float64, hostname string, tags []string)
- func (m *MockSender) MonotonicCount(metric string, value float64, hostname string, tags []string)
- func (m *MockSender) Rate(metric string, value float64, hostname string, tags []string)
- func (m *MockSender) ResetCalls()
- func (m *MockSender) ServiceCheck(checkName string, status metrics.ServiceCheckStatus, hostname string, ...)
- func (m *MockSender) SetCheckCustomTags(tags []string)
- func (m *MockSender) SetupAcceptAll()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnythingBut ¶
func AnythingBut(expected interface{}) interface{}
AnythingBut match everything except the argument It builds a mock.argumentMatcher
func AssertFloatInRange ¶
AssertFloatInRange is a mock.argumentMatcher builder to be used in asserts. It allows to check if a metric value is in a given range instead of matching exactly.
func IsGreaterOrEqual ¶
func IsGreaterOrEqual(expectedMin float64) interface{}
IsGreaterOrEqual is a mock.argumentMatcher builder to be used in asserts. actual have to be greater or equal expectedMin
func MatchEventLike ¶
MatchEventLike is a mock.argumentMatcher builder to be used in asserts. It allows to check if an event is Equal on the following Event elements: AggregationKey, Priority, SourceTypeName, EventType, Host and Tag list Also do a timestamp comparison with a tolerance defined by allowedDelta
func MatchTagsContains ¶
func MatchTagsContains(expected []string) interface{}
MatchTagsContains is a mock.argumentMatcher builder to be used in asserts. It allows to check if tags are emitted, ignoring unexpected ones and order.
Types ¶
type MockSender ¶
MockSender allows mocking of the checks sender for unit testing
func NewMockSender ¶
func NewMockSender(id check.ID) *MockSender
NewMockSender initiates the aggregator and returns a functional mocked Sender for testing
func (*MockSender) AssertEvent ¶
func (m *MockSender) AssertEvent(t *testing.T, expectedEvent metrics.Event, allowedDelta time.Duration) bool
AssertEvent assert the expectedEvent was emitted with the following values: AggregationKey, Priority, SourceTypeName, EventType, Host and a Ts range weighted with the parameter allowedDelta
func (*MockSender) AssertEventMissing ¶
func (m *MockSender) AssertEventMissing(t *testing.T, expectedEvent metrics.Event, allowedDelta time.Duration) bool
AssertEventMissing assert the expectedEvent was never emitted with the following values: AggregationKey, Priority, SourceTypeName, EventType, Host and a Ts range weighted with the parameter allowedDelta
func (*MockSender) AssertHistogramBucket ¶
func (m *MockSender) AssertHistogramBucket(t *testing.T, method string, metric string, value int, lowerBound float64, upperBound float64, monotonic bool, hostname string, tags []string) bool
AssertHistogramBucket allows to assert a histogram bucket was emitted with given parameters. Additional tags over the ones specified don't make it fail
func (*MockSender) AssertMetric ¶
func (m *MockSender) AssertMetric(t *testing.T, method string, metric string, value float64, hostname string, tags []string) bool
AssertMetric allows to assert a metric was emitted with given parameters. Additional tags over the ones specified don't make it fail
func (*MockSender) AssertMetricInRange ¶
func (m *MockSender) AssertMetricInRange(t *testing.T, method string, metric string, min float64, max float64, hostname string, tags []string) bool
AssertMetricInRange allows to assert a metric was emitted with given parameters, with a value in a given range. Additional tags over the ones specified don't make it fail
func (*MockSender) AssertMetricNotTaggedWith ¶
func (m *MockSender) AssertMetricNotTaggedWith(t *testing.T, method string, metric string, tags []string) bool
AssertMetricNotTaggedWith allows to assert tags were never emitted for a metric.
func (*MockSender) AssertMetricTaggedWith ¶
func (m *MockSender) AssertMetricTaggedWith(t *testing.T, method string, metric string, tags []string) bool
AssertMetricTaggedWith allows to assert a metric was emitted with given tags, value and hostname not tested. Additional tags over the ones specified don't make it fail
func (*MockSender) AssertServiceCheck ¶
func (m *MockSender) AssertServiceCheck(t *testing.T, checkName string, status metrics.ServiceCheckStatus, hostname string, tags []string, message string) bool
AssertServiceCheck allows to assert a ServiceCheck was exclusively emitted with given parameters. Additional tags over the ones specified don't make it fail Assert the ServiceCheck wasn't called with any other possible status
func (*MockSender) Count ¶
func (m *MockSender) Count(metric string, value float64, hostname string, tags []string)
Count adds a count type to the mock calls.
func (*MockSender) Counter ¶
func (m *MockSender) Counter(metric string, value float64, hostname string, tags []string)
Counter adds a counter type to the mock calls.
func (*MockSender) DisableDefaultHostname ¶
func (m *MockSender) DisableDefaultHostname(d bool)
DisableDefaultHostname enables the hostname mock call.
func (*MockSender) Event ¶
func (m *MockSender) Event(e metrics.Event)
Event enables the event mock call.
func (*MockSender) Gauge ¶
func (m *MockSender) Gauge(metric string, value float64, hostname string, tags []string)
Gauge adds a gauge type to the mock calls.
func (*MockSender) GetMetricStats ¶
func (m *MockSender) GetMetricStats() map[string]int64
GetMetricStats enables the get metric stats mock call.
func (*MockSender) Histogram ¶
func (m *MockSender) Histogram(metric string, value float64, hostname string, tags []string)
Histogram adds a histogram type to the mock calls.
func (*MockSender) HistogramBucket ¶
func (m *MockSender) HistogramBucket(metric string, value int, lowerBound, upperBound float64, monotonic bool, hostname string, tags []string)
HistogramBucket enables the histogram bucket mock call.
func (*MockSender) Historate ¶
func (m *MockSender) Historate(metric string, value float64, hostname string, tags []string)
Historate adds a historate type to the mock calls.
func (*MockSender) MonotonicCount ¶
func (m *MockSender) MonotonicCount(metric string, value float64, hostname string, tags []string)
MonotonicCount adds a monotonic count type to the mock calls.
func (*MockSender) Rate ¶
func (m *MockSender) Rate(metric string, value float64, hostname string, tags []string)
Rate adds a rate type to the mock calls.
func (*MockSender) ResetCalls ¶
func (m *MockSender) ResetCalls()
ResetCalls makes the mock forget previous calls
func (*MockSender) ServiceCheck ¶
func (m *MockSender) ServiceCheck(checkName string, status metrics.ServiceCheckStatus, hostname string, tags []string, message string)
ServiceCheck enables the service check mock call.
func (*MockSender) SetCheckCustomTags ¶
func (m *MockSender) SetCheckCustomTags(tags []string)
SetCheckCustomTags enables the set of check custom tags mock call.
func (*MockSender) SetupAcceptAll ¶
func (m *MockSender) SetupAcceptAll()
SetupAcceptAll sets mock expectations to accept any call in the Sender interface