Sha256: 24a76f1c9dc885868063cfb343710eb55c351d8f1b821a8b3de79975cb9053dd
Contents?: true
Size: 1.98 KB
Versions: 3
Compression:
Stored size: 1.98 KB
Contents
require 'test_helper' class MetricTest < Minitest::Test def test_required_arguments assert_raises(ArgumentError) { StatsD::Instrument::Metric.new(type: :c) } assert_raises(ArgumentError) { StatsD::Instrument::Metric.new(name: 'test') } assert_raises(ArgumentError) { StatsD::Instrument::Metric.new(type: :ms, name: 'test') } end def test_default_values m = StatsD::Instrument::Metric.new(type: :c, name: 'counter') assert_equal 1, m.value assert_equal StatsD.default_sample_rate, m.sample_rate assert m.tags.nil? end def test_name_prefix StatsD.stubs(:prefix).returns('prefix') m = StatsD::Instrument::Metric.new(type: :c, name: 'counter') assert_equal 'prefix.counter', m.name m = StatsD::Instrument::Metric.new(type: :c, name: 'counter', no_prefix: true) assert_equal 'counter', m.name m = StatsD::Instrument::Metric.new(type: :c, name: 'counter', prefix: "foobar") assert_equal 'foobar.counter', m.name m = StatsD::Instrument::Metric.new(type: :c, name: 'counter', prefix: "foobar", no_prefix: true) assert_equal 'counter', m.name end def test_bad_metric_name m = StatsD::Instrument::Metric.new(type: :c, name: 'my:metric', no_prefix: true) assert_equal 'my_metric', m.name m = StatsD::Instrument::Metric.new(type: :c, name: 'my|metric', no_prefix: true) assert_equal 'my_metric', m.name m = StatsD::Instrument::Metric.new(type: :c, name: 'my@metric', no_prefix: true) assert_equal 'my_metric', m.name end def test_handle_bad_tags assert_equal ['ignored'], StatsD::Instrument::Metric.normalize_tags(['igno|red']) assert_equal ['lol::class:omg::lol'], StatsD::Instrument::Metric.normalize_tags({ :"lol::class" => "omg::lol" }) end def test_rewrite_tags_provided_as_hash assert_equal ['tag:value'], StatsD::Instrument::Metric.normalize_tags(:tag => 'value') assert_equal ['tag:value', 'tag2:value2'], StatsD::Instrument::Metric.normalize_tags(:tag => 'value', :tag2 => 'value2') end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
statsd-instrument-2.3.5 | test/metric_test.rb |
statsd-instrument-2.3.4 | test/metric_test.rb |
statsd-instrument-2.3.2 | test/metric_test.rb |