diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index fd398716820a6111b59417d956f5741a2b98c7cb..a819e57515ecca67105c5bf011f991e9278440c2 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -6,6 +6,9 @@ ARGV.extend(HomebrewArgvExtension) require 'test/testball' require 'utils' +class AbstractDownloadStrategy + attr_reader :url +end class MostlyAbstractFormula <Formula @url='' @@ -50,5 +53,13 @@ class FormulaTests < Test::Unit::TestCase assert_raises(RuntimeError) { f.prefix } nostdout { assert_raises(RuntimeError) { f.brew } } end - + + def test_mirror_support + HOMEBREW_CACHE.mkpath unless HOMEBREW_CACHE.exist? + f = TestBallWithMirror.new + tarball, downloader = f.fetch + + assert_equal f.url, "file:///#{TEST_FOLDER}/bad_url/testball-0.1.tbz" + assert_equal downloader.url, "file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" + end end diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb index 97a161e1c57330f6f8191bab389643ece1d79bc6..aae18115c4933314e63a6c5872031bc44d12f4cd 100644 --- a/Library/Homebrew/test/testball.rb +++ b/Library/Homebrew/test/testball.rb @@ -13,6 +13,18 @@ class TestBall <Formula end end +class TestBallWithMirror < Formula + # `url` is bogus---curl should fail to download it. The mirror is fine + # though. + url "file:///#{TEST_FOLDER}/bad_url/testball-0.1.tbz" + mirror "file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" + + def initialize name=nil + @homepage = 'http://example.com/' + super "testballwithmirror" + end +end + class ConfigureFails <Formula # name parameter required for some Formula::factory def initialize name=nil