-
Notifications
You must be signed in to change notification settings - Fork 51
/
librato_metrics_reporter_test.rb
43 lines (34 loc) · 1.13 KB
/
librato_metrics_reporter_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'test_helper'
require 'thread_error_handling_tests'
require 'metriks/reporter/librato_metrics'
class LibratoMetricsReporterTest < Test::Unit::TestCase
include ThreadErrorHandlingTests
def build_reporter(options={})
Metriks::Reporter::LibratoMetrics.new('user', 'password', { :registry => @registry }.merge(options))
end
def setup
@registry = Metriks::Registry.new
@reporter = build_reporter
end
def teardown
@reporter.stop
@registry.stop
end
def test_write
@registry.meter('meter.testing').mark
@registry.counter('counter.testing').increment
@registry.timer('timer.testing').update(1.5)
@registry.histogram('histogram.testing').update(1.5)
@registry.utilization_timer('utilization_timer.testing').update(1.5)
@registry.gauge('gauge.testing') { 123 }
@reporter.expects(:submit).with do |data|
data.detect { |(k,v)| k =~ /gauges\[\d+\]\[name\]/ && v == 'gauge.testing' } &&
data.detect { |(k,v)| k =~ /gauges\[\d+\]\[value\]/ && v.to_s == '123' }
end
@reporter.write
end
def test_empty_write
@reporter.expects(:submit).never
@reporter.write
end
end