Sha256: 4e505f65b196c1d6765076a6b8a2c2a7a2915a35f86ec6ed8c3a4a3eafdaeaf4

Contents?: true

Size: 1.22 KB

Versions: 41

Compression:

Stored size: 1.22 KB

Contents

require_relative 'helper'
require 'fluent/file_wrapper'

class FileWrapperTest < Test::Unit::TestCase
  TMP_DIR = File.dirname(__FILE__) + "/../tmp/file_wrapper#{ENV['TEST_ENV_NUMBER']}"

  def setup
    FileUtils.mkdir_p(TMP_DIR)
  end

  def teardown
    FileUtils.rm_rf(TMP_DIR)
  end

  sub_test_case 'WindowsFile exceptions' do
    test 'nothing raised' do
      begin
        path = "#{TMP_DIR}/test_windows_file.txt"
        file1 = file2 = nil
        file1 = File.open(path, "wb") do |f|
        end
        assert_nothing_raised do
          file2 = Fluent::WindowsFile.new(path)
        ensure
          file2.close
        end
      ensure
        file1.close if file1
      end
    end

    test 'Errno::ENOENT raised' do
      path = "#{TMP_DIR}/nofile.txt"
      file = nil
      assert_raise(Errno::ENOENT) do
        file = Fluent::WindowsFile.new(path)
      ensure
        file.close if file
      end
    end

    test 'Errno::ENOENT raised on DeletePending' do
      path = "#{TMP_DIR}/deletepending.txt"
      file = Fluent::WindowsFile.new(path, mode='w')
      File.delete(path)
      assert_raise(Errno::ENOENT) do
        file.stat
      ensure
        file.close if file
      end
    end
  end
end if Fluent.windows?

Version data entries

41 entries across 41 versions & 6 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/test_file_wrapper.rb
fluentd-1.16.6-x86-mingw32 test/test_file_wrapper.rb
fluentd-1.16.6-x64-mingw32 test/test_file_wrapper.rb
fluentd-1.16.6-x64-mingw-ucrt test/test_file_wrapper.rb
fluentd-1.16.6 test/test_file_wrapper.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/test_file_wrapper.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/test_file_wrapper.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/test_file_wrapper.rb
fluentd-1.17.0-x86-mingw32 test/test_file_wrapper.rb
fluentd-1.17.0-x64-mingw-ucrt test/test_file_wrapper.rb
fluentd-1.17.0-x64-mingw32 test/test_file_wrapper.rb
fluentd-1.17.0 test/test_file_wrapper.rb
fluentd-1.16.5-x64-mingw-ucrt test/test_file_wrapper.rb
fluentd-1.16.5-x86-mingw32 test/test_file_wrapper.rb
fluentd-1.16.5-x64-mingw32 test/test_file_wrapper.rb
fluentd-1.16.5 test/test_file_wrapper.rb
fluentd-1.16.4-x64-mingw-ucrt test/test_file_wrapper.rb
fluentd-1.16.4-x86-mingw32 test/test_file_wrapper.rb
fluentd-1.16.4-x64-mingw32 test/test_file_wrapper.rb
fluentd-1.16.4 test/test_file_wrapper.rb