Skip to content

Commit

Permalink
Merge pull request #2899 from ganmacs/fix-compress-test
Browse files Browse the repository at this point in the history
Make compress test stable
  • Loading branch information
ganmacs authored Mar 19, 2020
2 parents 5181d10 + 5a24a7a commit b18f995
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/plugin/test_compressable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
class CompressableTest < Test::Unit::TestCase
include Fluent::Plugin::Compressable

def compress_assert_equal(expected, actual)
e = Zlib::GzipReader.new(StringIO.new(expected)).read
a = Zlib::GzipReader.new(StringIO.new(actual)).read
assert_equal(e, a)
end

sub_test_case '#compress' do
setup do
@src = 'text data for compressing' * 5
Expand All @@ -18,8 +24,7 @@ class CompressableTest < Test::Unit::TestCase
test 'write compressed data to IO with output_io option' do
io = StringIO.new
compress(@src, output_io: io)
waiting(10){ sleep 0.1 until @gzipped_src == io.string }
assert_equal @gzipped_src, io.string
compress_assert_equal @gzipped_src, io.string
end
end

Expand All @@ -36,7 +41,6 @@ class CompressableTest < Test::Unit::TestCase
test 'write decompressed data to IO with output_io option' do
io = StringIO.new
decompress(@gzipped_src, output_io: io)
waiting(10){ sleep 0.1 until @src == io.string }
assert_equal @src, io.string
end

Expand All @@ -58,7 +62,6 @@ class CompressableTest < Test::Unit::TestCase
output_io = StringIO.new

decompress(input_io: input_io, output_io: output_io)
waiting(10){ sleep 0.1 until @src == output_io.string }
assert_equal @src, output_io.string
end

Expand Down

0 comments on commit b18f995

Please sign in to comment.