Sha256: d8816f8cfd4ebe798575711d4ee7554a24970d9424cd1644befc31fe522227c5

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# encoding: UTF-8
require_relative 'spec_helper'

describe Fluent::LatencyOutput do
  before { Fluent::Test.setup }
  let(:config) { %[] }
  let(:tag) { 'tag' }
  let(:driver) { Fluent::Test::OutputTestDriver.new(Fluent::LatencyOutput, tag).configure(config) }

  describe 'test configure' do
    subject { driver.instance }

    context "check default" do
      let(:config) { %[] }
      its(:tag) { should == 'latency' }
      its(:interval) { should == 60 }
    end

    context "check config" do
      let(:config) { %[tag tag\ninterval 120]}
      its(:tag) { should == 'tag' }
      its(:interval) { should == 120 }
    end
  end

  describe 'test emit' do
    let(:emit_time) { Time.utc(1,1,1,1,1,2010,nil,nil,nil,nil).to_i }
    let(:current_time) { Time.utc(2,1,1,1,1,2010,nil,nil,nil,nil).to_i }
    let(:message) { "INFO GET /ping" }
    let(:expected) { {"max" => 1.0, "avg" => 1.0, "num" => 1} }
    before {
      Timecop.freeze(Time.at(current_time))
      Fluent::Engine.should_receive(:emit).with("latency", current_time, expected)
    }
    after  { Timecop.return }
    it {
      driver.run { driver.emit({'message' => message}, emit_time) }
      driver.instance.flush_emit
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-latency-0.0.2 spec/out_latency_spec.rb
fluent-plugin-latency-0.0.1 spec/out_latency.rb