about summary refs log tree commit homepage
path: root/test/test_fresh.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-12-24 20:20:00 +0000
committerEric Wong <normalperson@yhbt.net>2012-12-24 20:23:12 +0000
commitc0b3faa0922d895e6aafa9802df69649b1977eae (patch)
treee58ad4f186322b8f2ca1a007bb0b3c031b23a212 /test/test_fresh.rb
parentde18522959de92865bb10582dd02276b3da8ae01 (diff)
downloadmogilefs-client-c0b3faa0922d895e6aafa9802df69649b1977eae.tar.gz
IO.copy_stream does not raise EOFError when specified
copy length is less than input size.  Thus we must rely
on the MogileFS tracker to validate the input size.
Diffstat (limited to 'test/test_fresh.rb')
-rw-r--r--test/test_fresh.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_fresh.rb b/test/test_fresh.rb
index b619a6a..706783e 100644
--- a/test/test_fresh.rb
+++ b/test/test_fresh.rb
@@ -147,4 +147,22 @@ class TestMogFresh < Test::Unit::TestCase
     end
     src.close!
   end
+
+  def test_new_file_copy_stream_known_length
+    add_host_device_domain
+    opts = { :content_length => 666 }
+    input = StringIO.new("short")
+    client = MogileFS::MogileFS.new :hosts => @hosts, :domain => @domain
+    assert_raises(MogileFS::SizeMismatchError) do
+      client.new_file("copy_stream", opts) do |io|
+        IO.copy_stream(input, io)
+      end
+    end
+
+    assert_raises(MogileFS::SizeMismatchError) do
+      client.new_file("copy_stream", opts) do |io|
+        IO.copy_stream(input, io, 666)
+      end
+    end
+  end if IO.respond_to?(:copy_stream)
 end