lib/fluent/test/output_test.rb in fluentd-0.12.5 vs lib/fluent/test/output_test.rb in fluentd-0.12.6
- old
+ new
@@ -50,10 +50,14 @@
def initialize(klass, tag='test', &block)
super(klass, &block)
@entries = []
@expected_buffer = nil
@tag = tag
+
+ def @instance.buffer
+ @buffer
+ end
end
attr_accessor :tag
def emit(record, time=Time.now)
@@ -81,11 +85,16 @@
if @instance.respond_to?(:time_slicer)
# this block is only for test_out_file
time, record = @entries.first
key = @instance.time_slicer.call(time)
end
- chunk = MemoryBufferChunk.new(key, buffer)
- result = @instance.write(chunk)
+ chunk = @instance.buffer.new_chunk(key)
+ chunk << buffer
+ begin
+ result = @instance.write(chunk)
+ ensure
+ chunk.purge
+ end
}
result
end
end