Sha256: 0cd61145a6e4b1267742a107f17b29e54a9140d37efb48d0e3999e6929eb86cf

Contents?: true

Size: 1.33 KB

Versions: 72

Compression:

Stored size: 1.33 KB

Contents

require 'test_helper'

class ZipFileExtractDirectoryTest < MiniTest::Test
  include CommonZipFileFixture

  TEST_OUT_NAME = "test/data/generated/emptyOutDir"

  def open_zip(&aProc)
    assert(aProc != nil)
    ::Zip::File.open(TestZipFile::TEST_ZIP4.zip_name, &aProc)
  end

  def extract_test_dir(&aProc)
    open_zip {
        |zf|
      zf.extract(TestFiles::EMPTY_TEST_DIR, TEST_OUT_NAME, &aProc)
    }
  end

  def setup
    super

    Dir.rmdir(TEST_OUT_NAME) if File.directory? TEST_OUT_NAME
    File.delete(TEST_OUT_NAME) if File.exist? TEST_OUT_NAME
  end

  def test_extractDirectory
    extract_test_dir
    assert(File.directory?(TEST_OUT_NAME))
  end

  def test_extractDirectoryExistsAsDir
    Dir.mkdir TEST_OUT_NAME
    extract_test_dir
    assert(File.directory?(TEST_OUT_NAME))
  end

  def test_extractDirectoryExistsAsFile
    File.open(TEST_OUT_NAME, "w") { |f| f.puts "something" }
    assert_raises(::Zip::DestinationFileExistsError) { extract_test_dir }
  end

  def test_extractDirectoryExistsAsFileOverwrite
    File.open(TEST_OUT_NAME, "w") { |f| f.puts "something" }
    gotCalled = false
    extract_test_dir {
        |entry, destPath|
      gotCalled = true
      assert_equal(TEST_OUT_NAME, destPath)
      assert(entry.directory?)
      true
    }
    assert(gotCalled)
    assert(File.directory?(TEST_OUT_NAME))
  end
end

Version data entries

72 entries across 69 versions & 20 rubygems

Version Path
logstash-output-scalyr-0.1.9 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-scalyr-0.1.8 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-scalyr-0.1.7 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-scalyr-0.1.6 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-newrelic-1.2.0 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-scalyr-0.1.5 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-scalyr-0.1.4 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-scalyr-0.1.3 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-scalyr-0.1.2 vendor/bundle/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb