diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-28 07:10:25 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-28 07:10:25 +0000 |
commit | 8085eba3a203959588129eaced349c55a3a97377 (patch) | |
tree | 2acb3ab276b28320e9a84f8f23988d96e13ded76 /test/net/ftp/test_ftp.rb | |
parent | 6b3b9965421f8a8320af0f5c10d285f5a2739d27 (diff) | |
download | ruby-8085eba3a203959588129eaced349c55a3a97377.tar.gz |
* lib/net/ftp.rb (mtime): parse decimal fractions of a second as
specified in RFC 3659.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/ftp/test_ftp.rb')
-rw-r--r-- | test/net/ftp/test_ftp.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index 9fc163bc7b..c84dbda10f 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -1097,6 +1097,44 @@ EOF end end + def test_mtime + commands = [] + server = create_ftp_server { |sock| + sock.print("220 (test_ftp).\r\n") + commands.push(sock.gets) + sock.print("213 20150910161739\r\n") + commands.push(sock.gets) + sock.print("213 20150910161739\r\n") + commands.push(sock.gets) + sock.print("213 20150910161739.123456\r\n") + commands.push(sock.gets) + sock.print("213 2015091016173\r\n") + } + begin + begin + ftp = Net::FTP.new + ftp.connect(SERVER_ADDR, server.port) + assert_equal(Time.utc(2015, 9, 10, 16, 17, 39), ftp.mtime("foo.txt")) + assert_equal(Time.local(2015, 9, 10, 16, 17, 39), + ftp.mtime("foo.txt", true)) + assert_equal(Time.utc(2015, 9, 10, 16, 17, 39, 123456), + ftp.mtime("bar.txt")) + assert_raise(Net::FTPProtoError) do + ftp.mtime("quux.txt") + end + assert_match("MDTM foo.txt\r\n", commands.shift) + assert_match("MDTM foo.txt\r\n", commands.shift) + assert_match("MDTM bar.txt\r\n", commands.shift) + assert_match("MDTM quux.txt\r\n", commands.shift) + assert_equal(nil, commands.shift) + ensure + ftp.close if ftp + end + ensure + server.close + end + end + def test_system commands = [] server = create_ftp_server { |sock| |