aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-04-13 16:36:30 -0500
committerJack Nagel2013-04-13 16:36:30 -0500
commita722605dd59c48f332f21ca88bf79abc9e460ace (patch)
tree51f7724048d12f6c50cea79097fc385b1c30c728 /Library
parent84c7d9dea32b6351be6c40deb4a815c491f3b126 (diff)
downloadhomebrew-a722605dd59c48f332f21ca88bf79abc9e460ace.tar.bz2
Clean up checksum verification tests
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_checksum_verification.rb49
-rw-r--r--Library/Homebrew/test/test_checksums.rb50
2 files changed, 49 insertions, 50 deletions
diff --git a/Library/Homebrew/test/test_checksum_verification.rb b/Library/Homebrew/test/test_checksum_verification.rb
new file mode 100644
index 000000000..a97cd985a
--- /dev/null
+++ b/Library/Homebrew/test/test_checksum_verification.rb
@@ -0,0 +1,49 @@
+require 'testing_env'
+require 'test/testball'
+
+class ChecksumTests < Test::Unit::TestCase
+ def assert_checksum_good
+ assert_nothing_raised { shutup { @_f.brew {} } }
+ end
+
+ def assert_checksum_bad
+ assert_raises(ChecksumMismatchError) { shutup { @_f.brew {} } }
+ end
+
+ def formula(&block)
+ @_f = TestBall.new
+ @_f.stable.instance_eval(&block)
+ end
+
+ def test_good_sha1
+ formula do
+ sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5'
+ end
+
+ assert_checksum_good
+ end
+
+ def test_bad_sha1
+ formula do
+ sha1 '7ea8a98acb8f918df723c2ae73fe67d5664bfd7e'
+ end
+
+ assert_checksum_bad
+ end
+
+ def test_good_sha256
+ formula do
+ sha256 '1dfb13ce0f6143fe675b525fc9e168adb2215c5d5965c9f57306bb993170914f'
+ end
+
+ assert_checksum_good
+ end
+
+ def test_bad_sha256
+ formula do
+ sha256 'dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8'
+ end
+
+ assert_checksum_bad
+ end
+end
diff --git a/Library/Homebrew/test/test_checksums.rb b/Library/Homebrew/test/test_checksums.rb
deleted file mode 100644
index b5549e801..000000000
--- a/Library/Homebrew/test/test_checksums.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require 'testing_env'
-require 'test/testball'
-
-class ChecksumTests < Test::Unit::TestCase
- def good_checksum f
- assert_nothing_raised { shutup { f.brew {} } }
- end
-
- def bad_checksum f
- assert_raises ChecksumMismatchError do
- shutup { f.brew {} }
- end
- end
-
- def test_sha1
- valid_sha1 = TestBall.new
- valid_sha1.stable.instance_eval do
- sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5'
- end
-
- good_checksum valid_sha1
- end
-
- def test_badsha1
- invalid_sha1 = TestBall.new
- invalid_sha1.stable.instance_eval do
- sha1 '7ea8a98acb8f918df723c2ae73fe67d5664bfd7e'
- end
-
- bad_checksum invalid_sha1
- end
-
- def test_sha256
- valid_sha256 = TestBall.new
- valid_sha256.stable.instance_eval do
- sha256 '1dfb13ce0f6143fe675b525fc9e168adb2215c5d5965c9f57306bb993170914f'
- end
-
- good_checksum valid_sha256
- end
-
- def test_badsha256
- invalid_sha256 = TestBall.new
- invalid_sha256.stable.instance_eval do
- sha256 'dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8'
- end
-
- bad_checksum invalid_sha256
- end
-end