Skip to content

Commit

Permalink
Add logdevio tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ganmacs committed Sep 16, 2016
1 parent 04e369e commit 1542544
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/test_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -602,3 +602,60 @@ def test_terminate
plugin.terminate
end
end

class LogDeviceIOTest < Test::Unit::TestCase
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/tmp/logdeviceio/#{ENV['TEST_ENV_NUMBER']}")

def setup
FileUtils.rm_rf(TMP_DIR)
FileUtils.mkdir_p(TMP_DIR)
end

test 'rotate_age' do
logdev = Fluent::LogDeviceIO.new(TMP_DIR + '/rotate_age', shift_age: 2)
assert_equal 2, logdev.rotate_age
assert_equal 1048576, logdev.rotate_size
end

test 'rotate_size' do
logdev = Fluent::LogDeviceIO.new(TMP_DIR + '/rotate_size', shift_size: 100)
assert_equal 7, logdev.rotate_age
assert_equal 100, logdev.rotate_size
end

test 'flush' do
io = StringIO.new
logdev = Fluent::LogDeviceIO.new(io)
assert_equal io, logdev.flush

io.instance_eval { undef :flush }
logdev = Fluent::LogDeviceIO.new(io)
assert_raise NoMethodError do
logdev.flush
end
end

test 'tty?' do
io = StringIO.new
logdev = Fluent::LogDeviceIO.new(io)
assert_equal io.tty?, logdev.tty?

io.instance_eval { undef :tty? }
logdev = Fluent::LogDeviceIO.new(io)
assert_raise NoMethodError do
logdev.tty?
end
end

test 'sync=' do
io = StringIO.new
logdev = Fluent::LogDeviceIO.new(io)
assert_true logdev.sync = true

io.instance_eval { undef :sync= }
logdev = Fluent::LogDeviceIO.new(io)
assert_raise NoMethodError do
logdev.sync = true
end
end
end

0 comments on commit 1542544

Please sign in to comment.