Sha256: 220c22d338b90396cf0611b32a0b43dff6493f2bc2996f4a1d95111cc4a41ad2

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

require 'test_helper'
require 'metriksd/librato_metrics_reporter'

class LibratoMetricsReporterTest < Test::Unit::TestCase
  def setup
    @registry = Metriksd::Registry.new(:ignore_current_timeslice => false)
    @reporter = Metriksd::LibratoMetricsReporter.new(@registry, :email => 'x', :api_key => 'y')
    @reporter.client.persistence = :test
  end
  
  def test_empty_flush
    assert !@reporter.flush
  end

  def test_flush
    data = Metriksd::Data.new(:client_id => $$, :time => Time.now.to_i, :type => 'meter', :name => 'b', :source => 'a', :one_minute_rate => 3.4)
    @registry.push(data)

    # There is something to flush the first time
    assert @reporter.flush

    # There is nothing to flush the next time
    assert !@reporter.flush
  end

  def test_start
    @reporter = Metriksd::LibratoMetricsReporter.new(@registry, :email => 'x', :api_key => 'y', :interval => 0.1)
    @reporter.client.persistence = :test

    @reporter.start

    data = Metriksd::Data.new(:client_id => $$, :time => Time.now.to_i, :type => 'meter', :name => 'b', :source => 'a', :one_minute_rate => 3.4)
    @registry.push(data)

    @reporter.stop
    @reporter.join

    assert @reporter.queue.persister.persisted.length == 1, @reporter.queue.persister.persisted.inspect
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
metriksd-0.5.7 test/librato_metrics_reporter_test.rb
metriksd-0.5.6 test/librato_metrics_reporter_test.rb
metriksd-0.5.5 test/librato_metrics_reporter_test.rb
metriksd-0.5.4 test/librato_metrics_reporter_test.rb
metriksd-0.5.3 test/librato_metrics_reporter_test.rb
metriksd-0.5.2 test/librato_metrics_reporter_test.rb
metriksd-0.5.1 test/librato_metrics_reporter_test.rb
metriksd-0.5.0 test/librato_metrics_reporter_test.rb