2011-06-23 18:11:55 -04:00
|
|
|
require File.expand_path('../helper', __FILE__)
|
2009-10-02 15:07:55 -04:00
|
|
|
require 'date'
|
|
|
|
require 'time'
|
|
|
|
require 'rake/contrib/ftptools'
|
|
|
|
|
2011-06-23 18:11:55 -04:00
|
|
|
class FakeDate
|
|
|
|
def self.today
|
2013-10-11 17:35:01 -04:00
|
|
|
Date.new(2003, 10, 3)
|
2009-10-03 10:54:18 -04:00
|
|
|
end
|
2013-10-11 17:35:01 -04:00
|
|
|
|
2011-06-23 18:11:55 -04:00
|
|
|
def self.now
|
2013-10-11 17:35:01 -04:00
|
|
|
Time.local(2003, 10, 3, 12, 00, 00)
|
2011-06-23 18:11:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class TestRakeFtpFile < Rake::TestCase
|
2009-10-02 15:07:55 -04:00
|
|
|
|
|
|
|
def setup
|
2011-06-23 18:11:55 -04:00
|
|
|
super
|
|
|
|
|
2013-10-11 17:35:01 -04:00
|
|
|
Rake::FtpFile.class_eval {
|
|
|
|
@date_class = FakeDate
|
|
|
|
@time_class = FakeDate
|
|
|
|
}
|
2009-10-02 15:07:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_general
|
2013-10-11 17:35:01 -04:00
|
|
|
file = Rake::FtpFile.new(
|
|
|
|
"here",
|
|
|
|
"-rw-r--r-- 1 a279376 develop 121770 Mar 6 14:50 wiki.pl")
|
2009-10-02 15:07:55 -04:00
|
|
|
assert_equal "wiki.pl", file.name
|
|
|
|
assert_equal "here/wiki.pl", file.path
|
|
|
|
assert_equal "a279376", file.owner
|
|
|
|
assert_equal "develop", file.group
|
|
|
|
assert_equal 0644, file.mode
|
2013-10-11 17:35:01 -04:00
|
|
|
assert_equal 121_770, file.size
|
|
|
|
assert_equal Time.mktime(2003, 3, 6, 14, 50, 0, 0), file.time
|
2009-10-02 15:07:55 -04:00
|
|
|
assert ! file.directory?
|
|
|
|
assert ! file.symlink?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_far_date
|
2013-10-11 17:35:01 -04:00
|
|
|
file = Rake::FtpFile.new(
|
|
|
|
".",
|
|
|
|
"drwxr-xr-x 3 a279376 develop 4096 Nov 26 2001 vss")
|
|
|
|
assert_equal Time.mktime(2001, 11, 26, 0, 0, 0, 0), file.time
|
2009-10-02 15:07:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_close_date
|
2013-10-11 17:35:01 -04:00
|
|
|
file = Rake::FtpFile.new(
|
|
|
|
".",
|
|
|
|
"drwxr-xr-x 3 a279376 develop 4096 Nov 26 15:35 vss")
|
|
|
|
assert_equal Time.mktime(2002, 11, 26, 15, 35, 0, 0), file.time
|
2009-10-02 15:07:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_directory
|
2013-10-11 17:35:01 -04:00
|
|
|
file = Rake::FtpFile.new(
|
|
|
|
".",
|
|
|
|
"drwxrwxr-x 9 a279376 develop 4096 Mar 13 14:32 working")
|
2009-10-02 15:07:55 -04:00
|
|
|
assert file.directory?
|
|
|
|
assert !file.symlink?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_symlink
|
2013-10-11 17:35:01 -04:00
|
|
|
file = Rake::FtpFile.new(
|
|
|
|
".",
|
|
|
|
"lrwxrwxrwx 1 a279376 develop 64 Mar 26 2002 " +
|
|
|
|
"xtrac -> /home/a279376/working/ics/development/java/" +
|
|
|
|
"com/fmr/fwp/ics/xtrac")
|
2009-10-02 15:07:55 -04:00
|
|
|
assert_equal 'xtrac', file.name
|
|
|
|
assert file.symlink?
|
|
|
|
assert !file.directory?
|
|
|
|
end
|
|
|
|
end
|