diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-10-18 10:28:18 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-18 10:28:18 +0000 |
commit | ab067831e707b191d6dfdcd01de1f1d85fc90d05 (patch) | |
tree | b02861eb1521fb325ee4e1d91e1a194ca73e7a9e /test/test_stream_file.rb | |
download | yahns-ab067831e707b191d6dfdcd01de1f1d85fc90d05.tar.gz |
Diffstat (limited to 'test/test_stream_file.rb')
-rw-r--r-- | test/test_stream_file.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/test_stream_file.rb b/test/test_stream_file.rb new file mode 100644 index 0000000..6574a97 --- /dev/null +++ b/test/test_stream_file.rb @@ -0,0 +1,30 @@ +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require_relative 'helper' +require 'timeout' + +class TestStreamFile < Testcase + parallelize_me! + DevFD = Struct.new(:to_path) + + def test_stream_file + fp = File.open("COPYING") + sf = Yahns::StreamFile.new(fp, true, 0, fp.stat.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.stat.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 |