brew/Library/Homebrew/test/checksum_verification_test.rb
Alyssa Ross 70a381a00f tests: enforce super in lifecycle hooks
This will allow us to have global setup and teardown for tests.

For example, we can automatically clear caches after each test, to avoid
annoying intermittent failures like #1879 and #1886.
2017-01-21 11:34:52 +00:00

41 lines
745 B
Ruby

require "testing_env"
require "formula"
class ChecksumVerificationTests < Homebrew::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)
super do
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
instance_eval(&block)
end
end
def teardown
@_f.clear_cache
super
end
def test_good_sha256
formula do
sha256 TESTBALL_SHA256
end
assert_checksum_good
end
def test_bad_sha256
formula do
sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8"
end
assert_checksum_bad
end
end