diff options
Diffstat (limited to 'test/test_fresh.rb')
-rw-r--r-- | test/test_fresh.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/test_fresh.rb b/test/test_fresh.rb index 369e363..a87ebd5 100644 --- a/test/test_fresh.rb +++ b/test/test_fresh.rb @@ -90,4 +90,30 @@ class TestMogFresh < Test::Unit::TestCase ensure @admin.delete_class @domain, "check" end + + def test_create_open_close_opts + add_host_device_domain + client = MogileFS::MogileFS.new :hosts => @hosts, :domain => @domain + socket = client.backend.socket + args = { + :create_open_args => { :hello => "world" }, + :create_close_args => { :farewell => "goodnight" }, + } + io = client.new_file("foo", args) + socket.write "!recent\n" + buf = "" + buf << socket.readpartial(666) until buf =~ /\.\r?\n\z/ + line = buf.split(/\r?\n/).grep(/\screate_open\s/)[0] + assert_equal 0, buf.split(/\r?\n/).grep(/\screate_close\s/).size + assert_equal 0, buf.split(/\r?\n/).grep(/\sfarewell\s/).size + assert_match /\bhello=world\b/, line + assert_equal 1, io.write('.') + assert_nil io.close + + socket.write "!recent\n" + buf = "" + buf << socket.readpartial(666) until buf =~ /\.\r?\n\z/ + line = buf.split(/\r?\n/).grep(/\screate_close\s/)[0] + assert_match /\bfarewell=goodnight\b/, line + end end |