Sha256: f99522f6067e3bd0258d8ca5dccae86bb1cd11cb17e44132f4ecdfaad569e546

Contents?: true

Size: 870 Bytes

Versions: 13

Compression:

Stored size: 870 Bytes

Contents

# Copyright (C) 2013-2016 all contributors <yahns-public@yhbt.net>
# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
# frozen_string_literal: true
require_relative 'helper'
require 'timeout'

class TestStreamFile < Testcase
  ENV["N"].to_i > 1 and parallelize_me!
  DevFD = Struct.new(:to_path)

  def test_stream_file
    fp = File.open("COPYING")
    sf = Yahns::StreamFile.new(fp, true, 0, fp.size)
    refute sf.respond_to?(:close)
    sf.wbuf_close(nil)
    assert fp.closed?
  end

  def test_fd
    fp = File.open("COPYING")
    obj = DevFD.new("/dev/fd/#{fp.fileno}")
    sf = Yahns::StreamFile.new(obj, true, 0, fp.size)
    io = sf.instance_variable_get :@tmpio
    assert_instance_of IO, io.to_io
    assert_equal fp.fileno, io.fileno
    refute sf.respond_to?(:close)
    sf.wbuf_close(nil)
    refute fp.closed?
    refute io.closed?
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
yahns-1.18.0 test/test_stream_file.rb
yahns-1.17.0 test/test_stream_file.rb
yahns-1.16.0 test/test_stream_file.rb
yahns-1.15.0 test/test_stream_file.rb
yahns-1.14.1 test/test_stream_file.rb
yahns-1.14.0 test/test_stream_file.rb
yahns-1.13.0 test/test_stream_file.rb
yahns-1.12.5 test/test_stream_file.rb
yahns-1.12.4 test/test_stream_file.rb
yahns-1.12.3 test/test_stream_file.rb
yahns-1.12.2 test/test_stream_file.rb
yahns-1.12.1 test/test_stream_file.rb
yahns-1.12.0 test/test_stream_file.rb