Sha256: a4a5a2a218648ed7b30d16129c3814562c8e5e14e81164efa177fdaa4a61cb15

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

require_relative '../helper'
require 'fluent/plugin/file_wrapper'

class FileWrapperTest < Test::Unit::TestCase
  require 'windows/file'
  require 'windows/error'
  include Windows::File
  include Windows::Error

  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

10 entries across 10 versions & 2 rubygems

Version Path
fluentd-1.15.1-x86-mingw32 test/plugin/test_file_wrapper.rb
fluentd-1.15.1-x64-mingw32 test/plugin/test_file_wrapper.rb
fluentd-1.15.1-x64-mingw-ucrt test/plugin/test_file_wrapper.rb
fluentd-1.15.1 test/plugin/test_file_wrapper.rb
fluentd-1.15.0-x86-mingw32 test/plugin/test_file_wrapper.rb
fluentd-1.15.0-x64-mingw-ucrt test/plugin/test_file_wrapper.rb
fluentd-1.15.0-x64-mingw32 test/plugin/test_file_wrapper.rb
fluentd-1.15.0 test/plugin/test_file_wrapper.rb
dtomasgu-fluentd-1.14.8.pre.dev test/plugin/test_file_wrapper.rb
dtomasgu-fluentd-1.14.7.pre.dev test/plugin/test_file_wrapper.rb