class CPIOArchiveReaderTest
Constants
- CPIOFixture
- ExpectedFixtureHashes
These are SHA1 hashes
Public Instance Methods
test_given_a_archive_with_a_bad_magic_number_should_raise()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 288 def test_given_a_archive_with_a_bad_magic_number_should_raise assert_raises(CPIO::ArchiveFormatError) do CPIO::ArchiveReader.new(StringIO.new('foo')).each_entry { } end end
test_given_a_archive_with_a_valid_magic_number_should_not_raise()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 294 def test_given_a_archive_with_a_valid_magic_number_should_not_raise archive = CPIO::ArchiveReader.new(CPIOFixture) assert_nil archive.each_entry { } end
test_given_a_valid_archive_should_have_correct_file_contents()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 334 def test_given_a_valid_archive_should_have_correct_file_contents expected = ExpectedFixtureHashes.size archive = CPIO::ArchiveReader.new(CPIOFixture) archive.each_entry do |ent| if (sha1_hash = ExpectedFixtureHashes[ent.filename]) && Digest::SHA1.hexdigest(ent.data) == sha1_hash expected -= 1 end end assert_equal 0, expected, "Expected all files in the archive to hash correctly." end
test_given_a_valid_archive_should_have_the_expected_entry_filenames()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 306 def test_given_a_valid_archive_should_have_the_expected_entry_filenames expected = %w[cpio_test cpio_test/test_dir cpio_test/test_dir/test_file cpio_test/test_executable] archive = CPIO::ArchiveReader.new(CPIOFixture) archive.each_entry { |ent| expected.delete(ent.filename) } assert_equal 0, expected.size, "The expected array should be empty but we still have: #{expected.inspect}" end
test_given_a_valid_archive_should_have_the_expected_number_of_directories()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 313 def test_given_a_valid_archive_should_have_the_expected_number_of_directories expected = 2 archive = CPIO::ArchiveReader.new(CPIOFixture) archive.each_entry { |ent| expected -= 1 if ent.directory? } assert_equal 0, expected end
test_given_a_valid_archive_should_have_the_expected_number_of_entries()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 299 def test_given_a_valid_archive_should_have_the_expected_number_of_entries archive = CPIO::ArchiveReader.new(CPIOFixture) entries = 4 archive.each_entry { |ent| entries -= 1 } assert_equal 0, entries, "Expected #{entries} in the archive." end
test_given_a_valid_archive_should_have_the_expected_number_of_executable_files()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 327 def test_given_a_valid_archive_should_have_the_expected_number_of_executable_files expected = 1 archive = CPIO::ArchiveReader.new(CPIOFixture) archive.each_entry { |ent| expected -= 1 if ent.file? && ent.executable? } assert_equal 0, expected end
test_given_a_valid_archive_should_have_the_expected_number_of_regular_files()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 320 def test_given_a_valid_archive_should_have_the_expected_number_of_regular_files expected = 1 archive = CPIO::ArchiveReader.new(CPIOFixture) archive.each_entry { |ent| expected -= 1 if ent.file? && !ent.executable? } assert_equal 0, expected end