test/test_datafile.rb in avro-1.7.4 vs test/test_datafile.rb in avro-1.7.5
- old
+ new
@@ -152,6 +152,37 @@
assert_equal "家", s
end
datafile.close
end
+ def test_deflate
+ Avro::DataFile.open('data.avr', 'w', '"string"', :deflate) do |writer|
+ writer << 'a' * 10_000
+ end
+ assert(File.size('data.avr') < 500)
+
+ records = []
+ Avro::DataFile.open('data.avr') do |reader|
+ reader.each {|record| records << record }
+ end
+ assert_equal records, ['a' * 10_000]
+ end
+
+ def test_append_to_deflated_file
+ schema = Avro::Schema.parse('"string"')
+ writer = Avro::IO::DatumWriter.new(schema)
+ file = Avro::DataFile::Writer.new(File.open('data.avr', 'wb'), writer, schema, :deflate)
+ file << 'a' * 10_000
+ file.close
+
+ file = Avro::DataFile::Writer.new(File.open('data.avr', 'a+b'), writer)
+ file << 'b' * 10_000
+ file.close
+ assert(File.size('data.avr') < 1_000)
+
+ records = []
+ Avro::DataFile.open('data.avr') do |reader|
+ reader.each {|record| records << record }
+ end
+ assert_equal records, ['a' * 10_000, 'b' * 10_000]
+ end
end