diff options
| author | Adam Vandenberg | 2010-03-16 12:08:34 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-04-06 08:27:11 -0700 |
| commit | 259ae27cc441d0fe273d5fcd8a8b72ac32d73ae7 (patch) | |
| tree | 5a718b03c1ac146474b15eeedd502e7442b3e220 /Library | |
| parent | 4c2a8a7f1c306cf539537056cce93d330a9df18a (diff) | |
| download | brew-259ae27cc441d0fe273d5fcd8a8b72ac32d73ae7.tar.bz2 | |
Move checksum tests to separate file.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/test_checksums.rb | 65 | ||||
| -rwxr-xr-x | Library/Homebrew/test/tests | 2 | ||||
| -rwxr-xr-x | Library/Homebrew/test/unittest.rb | 1 |
3 files changed, 47 insertions, 21 deletions
diff --git a/Library/Homebrew/test/test_checksums.rb b/Library/Homebrew/test/test_checksums.rb index d93af908a..a9208e7f6 100644 --- a/Library/Homebrew/test/test_checksums.rb +++ b/Library/Homebrew/test/test_checksums.rb @@ -1,57 +1,82 @@ +require 'testing_env' + +require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser +ARGV.extend(HomebrewArgvExtension) + +require 'formula' +require 'utils' + + +class TestBall <Formula + # name parameter required for some Formula::factory + def initialize name=nil + @url="file:///#{TEST_FOLDER}/testball-0.1.tbz" + @homepage = 'http://example.com/' + super "testball" + end + def install + prefix.install "bin" + prefix.install "libexec" + end +end + + class ChecksumTests < Test::Unit::TestCase + def good_checksum f + assert_nothing_raised { nostdout { f.new.brew {} } } + end + + def bad_checksum f + assert_raises RuntimeError do + nostdout { f.new.brew {} } + end + end + def test_md5 valid_md5 = Class.new(TestBall) do @md5='71aa838a9e4050d1876a295a9e62cbe6' end - - assert_nothing_raised { nostdout { valid_md5.new.brew {} } } + + good_checksum valid_md5 end def test_badmd5 invalid_md5 = Class.new(TestBall) do @md5='61aa838a9e4050d1876a295a9e62cbe6' end - - assert_raises RuntimeError do - nostdout { invalid_md5.new.brew {} } - end + + bad_checksum invalid_md5 end def test_sha1 valid_sha1 = Class.new(TestBall) do @sha1='6ea8a98acb8f918df723c2ae73fe67d5664bfd7e' end - - assert_nothing_raised { nostdout { valid_sha1.new.brew {} } } + + good_checksum valid_sha1 end def test_badsha1 invalid_sha1 = Class.new(TestBall) do @sha1='7ea8a98acb8f918df723c2ae73fe67d5664bfd7e' end - - assert_raises RuntimeError do - nostdout { invalid_sha1.new.brew {} } - end + + bad_checksum invalid_sha1 end def test_sha256 valid_sha256 = Class.new(TestBall) do @sha256='ccbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8' end - - assert_nothing_raised do - nostdout { valid_sha256.new.brew {} } - end + + good_checksum valid_sha256 end def test_badsha256 invalid_sha256 = Class.new(TestBall) do @sha256='dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8' end - - assert_raises RuntimeError do - nostdout { invalid_sha256.new.brew {} } - end + + bad_checksum invalid_sha256 end end diff --git a/Library/Homebrew/test/tests b/Library/Homebrew/test/tests index 093433acc..cf6e9b688 100755 --- a/Library/Homebrew/test/tests +++ b/Library/Homebrew/test/tests @@ -11,6 +11,8 @@ ruby unittest.rb $* ruby test_versions.rb $* +ruby test_checksums.rb $* + ruby test_inreplace.rb $* # Test hardware sniffers diff --git a/Library/Homebrew/test/unittest.rb b/Library/Homebrew/test/unittest.rb index 2b4ab377a..8e850705d 100755 --- a/Library/Homebrew/test/unittest.rb +++ b/Library/Homebrew/test/unittest.rb @@ -104,5 +104,4 @@ module ExtendArgvPlusYeast end ARGV.extend ExtendArgvPlusYeast -require 'test/test_checksums' require 'test/test_bucket' |
