Sha256: c780f88189010b5661c815c9006806de5b86912102ddda59bcd65c80395de6be
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
# encoding: UTF-8 require_relative 'spec_helper' describe Fluent::RecordReformerOutput do before { Fluent::Test.setup } CONFIG = %[ type reformed output_tag reformed hostname ${hostname} tag ${tag} time ${time.strftime('%S')} message ${hostname} ${tags.last} ${message} ] let(:tag) { 'test.tag' } let(:tags) { tag.split('.') } let(:hostname) { Socket.gethostname.chomp } let(:driver) { Fluent::Test::OutputTestDriver.new(Fluent::RecordReformerOutput, tag).configure(config) } describe 'test configure' do describe 'good configuration' do subject { driver.instance } context "check default" do let(:config) { CONFIG } its(:output_tag) { should == 'reformed' } end end end describe 'test emit' do let(:time) { Time.now } let(:emit) do driver.run do driver.emit({'foo'=>'bar', 'message' => 1}, time.to_i) driver.emit({'foo'=>'bar', 'message' => 2}, time.to_i) end end let(:config) { CONFIG } before do Fluent::Engine.stub(:now).and_return(time) Fluent::Engine.should_receive(:emit).with("reformed", time.to_i, { 'foo' => 'bar', 'hostname' => hostname, 'tag' => tag, 'time' => time.strftime('%S'), 'message' => "#{hostname} #{tags.last} 1", }) Fluent::Engine.should_receive(:emit).with("reformed", time.to_i, { 'foo' => 'bar', 'hostname' => hostname, 'tag' => tag, 'time' => time.strftime('%S'), 'message' => "#{hostname} #{tags.last} 2", }) end it { emit } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-record-reformer-0.0.2 | spec/out_record_expander_spec.rb |
fluent-plugin-record-reformer-0.0.1 | spec/out_record_expander_spec.rb |