Skip to content

Commit

Permalink
test: Use binmode for Tempfile
Browse files Browse the repository at this point in the history
In Windows, writing 0 contained contents should be written as binmode.
Otherwise, it will cause corrupted contents.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Mar 9, 2020
1 parent 53c6652 commit 7560a48
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions test/plugin/in_tail/test_position_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class IntailPositionFileTest < Test::Unit::TestCase
setup do
@file = Tempfile.new('intail_position_file_test')
@file = Tempfile.new('intail_position_file_test').binmode
end

teardown do
Expand Down Expand Up @@ -196,11 +196,7 @@ def build_files(file)
@file.seek(0)
lines = @file.readlines
assert_equal 2, lines.size
if Fluent.windows?
assert_equal "valid_path\t0000000000000000a\t000000000000000b\n", lines[0]
else
assert_equal "valid_path\t000000000000000a\t000000000000000b\n", lines[0]
end
assert_equal "valid_path\t000000000000000a\t000000000000000b\n", lines[0]
assert_equal "valid_path2\t0000000000000003\t0000000000000002\n", lines[1]
end

Expand All @@ -213,11 +209,7 @@ def build_files(file)
@file.seek(0)
lines = @file.readlines
assert_equal 2, lines.size
if Fluent.windows?
assert_equal "valid_path\t0000000000000000a0000000000000001\n", lines[0]
else
assert_equal "valid_path\t000000000000000a\t0000000000000001\n", lines[0]
end
assert_equal "valid_path\t000000000000000a\t0000000000000001\n", lines[0]
assert_equal "valid_path2\t0000000000000003\t0000000000000002\n", lines[1]
end

Expand Down

0 comments on commit 7560a48

Please sign in to comment.