Class: ADSP::Test::Stream::MinitarTest

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/adsp/test/stream/minitar.rb

Overview

ADSP::Test::Stream::MinitarTest class.

Constant Summary collapse

Reader =
Mock::Stream::Reader
Writer =
Mock::Stream::Writer
ARCHIVE_PATH =
Common::ARCHIVE_PATH
LARGE_TEXTS =
Common::LARGE_TEXTS

Instance Method Summary collapse

Instance Method Details

#test_tarObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/adsp/test/stream/minitar.rb', line 23

def test_tar
  Common.parallel LARGE_TEXTS do |text, worker_index|
    archive_path = Common.get_path ARCHIVE_PATH, worker_index

    Writer.open archive_path do |writer|
      Minitar::Writer.open writer do |tar|
        tar.add_file_simple "file", :data => text
      end
    end

    Reader.open archive_path do |reader|
      Minitar::Reader.open reader do |tar|
        tar.each_entry do |entry|
          assert_equal "file", entry.name

          decompressed_text = entry.read
          decompressed_text.force_encoding text.encoding

          assert_equal text, decompressed_text
        end
      end
    end
  end
end