<commit_before>require 'test_helper'

require 'metriks/reporter/riemann'

class RiemannReporterTest < Test::Unit::TestCase
  def setup
    @registry = Metriks::Registry.new
    @reporter = Metriks::Reporter::Riemann.new(
      :host => "foo",
      :port => 1234,
      :registry => @registry,
      :default_event => {:host => "h"}
    )
  end

  def teardown
    @reporter.stop
    @registry.stop
  end

  def test_init
    assert_equal @reporter.client.host, "foo"
    assert_equal @reporter.client.port, 1234
  end

  def test_write
    @registry.meter('meter.testing').mark
    @registry.counter('counter.testing').increment
    @registry.timer('timer.testing').update(1.5)
    @registry.utilization_timer('utilization_timer.testing').update(1.5)

    @reporter.client.expects(:<<).at_least_once
    @reporter.client.expects(:<<).with(
      :host => "h",
      :service => "meter.testing count",
      :metric => 1,
      :tags => ["meter"],
      :ttl => 90
    )
    @reporter.client.expects(:<<).with(
      :host => "h",
      :service => "counter.testing count",
      :metric => 1,
      :tags => ["counter"],
      :ttl => 90
    )
    @reporter.client.expects(:<<).with(
      :host => "h",
      :service => "timer.testing max",
      :metric => 1.5,
      :tags => ["timer"],
      :ttl => 90
    )
    @reporter.client.expects(:<<).with(
      :host => "h",
      :service => "utilization_timer.testing mean",
      :metric => 1.5,
      :tags => ["utilization_timer"],
      :ttl => 90
    )

    @reporter.write
  end
end
<commit_msg>Ensure the riemann tests only run in ruby 1.9<commit_after>require 'test_helper'

# riemann only works in 1.9
if RUBY_VERSION > '1.9'

require 'metriks/reporter/riemann'

class RiemannReporterTest < Test::Unit::TestCase
  def setup
    @registry = Metriks::Registry.new
    @reporter = Metriks::Reporter::Riemann.new(
      :host => "foo",
      :port => 1234,
      :registry => @registry,
      :default_event => {:host => "h"}
    )
  end

  def teardown
    @reporter.stop
    @registry.stop
  end

  def test_init
    assert_equal @reporter.client.host, "foo"
    assert_equal @reporter.client.port, 1234
  end

  def test_write
    @registry.meter('meter.testing').mark
    @registry.counter('counter.testing').increment
    @registry.timer('timer.testing').update(1.5)
    @registry.utilization_timer('utilization_timer.testing').update(1.5)

    @reporter.client.expects(:<<).at_least_once
    @reporter.client.expects(:<<).with(
      :host => "h",
      :service => "meter.testing count",
      :metric => 1,
      :tags => ["meter"],
      :ttl => 90
    )
    @reporter.client.expects(:<<).with(
      :host => "h",
      :service => "counter.testing count",
      :metric => 1,
      :tags => ["counter"],
      :ttl => 90
    )
    @reporter.client.expects(:<<).with(
      :host => "h",
      :service => "timer.testing max",
      :metric => 1.5,
      :tags => ["timer"],
      :ttl => 90
    )
    @reporter.client.expects(:<<).with(
      :host => "h",
      :service => "utilization_timer.testing mean",
      :metric => 1.5,
      :tags => ["utilization_timer"],
      :ttl => 90
    )

    @reporter.write
  end
end

end
{'fraction_non_alphanumeric': 0.17370892018779344, 'fraction_numerical': 0.01815336463223787, 'mean_word_length': 2.65675057208238, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2109634', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1094, 'n_words': 207}