test_download_strategies: add mtime test

This commit is contained in:
Xu Cheng 2016-01-14 20:33:10 +08:00
parent 7958343f16
commit 8deec537d1
3 changed files with 11 additions and 9 deletions

View File

@ -1,8 +0,0 @@
require "testing_env"
require "cmd/bottle"
class BottleTests < Homebrew::TestCase
def test_most_recent_mtime_with_broken_symlink()
refute_nil Homebrew.most_recent_mtime(Pathname(File.join(TEST_DIRECTORY, 'resources/source-with-broken-symlink')))
end
end

View File

@ -11,6 +11,8 @@ class ResourceDouble
end end
class AbstractDownloadStrategyTests < Homebrew::TestCase class AbstractDownloadStrategyTests < Homebrew::TestCase
include FileUtils
def setup def setup
@name = "foo" @name = "foo"
@resource = ResourceDouble.new @resource = ResourceDouble.new
@ -34,6 +36,15 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase
assert_equal %w[foo bar baz], @args assert_equal %w[foo bar baz], @args
refute_same @args, result refute_same @args, result
end end
def test_source_modified_time
mktemp "mtime" do
touch "foo", :mtime => Time.now - 10
touch "bar", :mtime => Time.now - 100
ln_s "not-exist", "baz"
assert_equal File.mtime("foo"), @strategy.source_modified_time
end
end
end end
class VCSDownloadStrategyTests < Homebrew::TestCase class VCSDownloadStrategyTests < Homebrew::TestCase