Extract constants for checkums in tests
This commit is contained in:
parent
5e0a8668fb
commit
291cdea687
@ -154,23 +154,17 @@ class FormulaTests < Test::Unit::TestCase
|
||||
homepage 'http://example.com'
|
||||
url 'file:///foo.com/testball-0.1.tbz'
|
||||
mirror 'file:///foo.org/testball-0.1.tbz'
|
||||
sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5'
|
||||
sha1 TEST_SHA1
|
||||
|
||||
head 'https://github.com/mxcl/homebrew.git', :tag => 'foo'
|
||||
|
||||
devel do
|
||||
url 'file:///foo.com/testball-0.2.tbz'
|
||||
mirror 'file:///foo.org/testball-0.2.tbz'
|
||||
sha256 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
|
||||
sha256 TEST_SHA256
|
||||
end
|
||||
|
||||
bottle do
|
||||
sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snow_leopard_32
|
||||
sha1 'faceb00cfaceb00cfaceb00cfaceb00cfaceb00c' => :snow_leopard
|
||||
sha1 'baadf00dbaadf00dbaadf00dbaadf00dbaadf00d' => :lion
|
||||
sha1 '8badf00d8badf00d8badf00d8badf00d8badf00d' => :mountain_lion
|
||||
sha1 'deadf00ddeadf00ddeadf00ddeadf00ddeadf00d' => :mavericks
|
||||
end
|
||||
bottle { sha1 TEST_SHA1 => bottle_tag }
|
||||
|
||||
def initialize(name="spec_test_ball", path=nil)
|
||||
super
|
||||
|
||||
@ -39,17 +39,7 @@ class FormulaSpecSelectionTests < Test::Unit::TestCase
|
||||
def install_bottle?(*); true; end
|
||||
|
||||
url 'foo-1.0'
|
||||
bottle do
|
||||
{
|
||||
:snow_leopard_32 => 'deadbeef'*5,
|
||||
:snow_leopard => 'faceb00c'*5,
|
||||
:lion => 'baadf00d'*5,
|
||||
:mountain_lion => '8badf00d'*5,
|
||||
:mavericks => 'deadf00d'*5
|
||||
}.each_pair do |cat, val|
|
||||
sha1(val => cat)
|
||||
end
|
||||
end
|
||||
bottle { sha1 TEST_SHA1 => bottle_tag }
|
||||
end
|
||||
|
||||
assert_spec_selected :bottle
|
||||
@ -100,7 +90,7 @@ class FormulaSpecSelectionTests < Test::Unit::TestCase
|
||||
|
||||
def test_incomplete_spec_not_selected
|
||||
formula do
|
||||
sha1 'deadbeef'*5
|
||||
sha1 TEST_SHA1
|
||||
version '1.0'
|
||||
head 'foo'
|
||||
end
|
||||
@ -110,7 +100,7 @@ class FormulaSpecSelectionTests < Test::Unit::TestCase
|
||||
|
||||
def test_incomplete_stable_not_set
|
||||
formula do
|
||||
sha1 'foo'
|
||||
sha1 TEST_SHA1
|
||||
devel { url 'foo-1.1a' }
|
||||
head 'foo'
|
||||
end
|
||||
@ -133,9 +123,7 @@ class FormulaSpecSelectionTests < Test::Unit::TestCase
|
||||
def test_incomplete_bottle_not_set
|
||||
formula do
|
||||
url 'foo-1.0'
|
||||
bottle do
|
||||
sha1 'deadbeef'*5 => :some_nonexistent_thing
|
||||
end
|
||||
bottle { sha1 TEST_SHA1 => :some_nonexistent_thing }
|
||||
end
|
||||
|
||||
assert_spec_unset :bottle
|
||||
|
||||
@ -88,10 +88,10 @@ class ResourceTests < Test::Unit::TestCase
|
||||
|
||||
def test_checksum_setters
|
||||
assert_nil @resource.checksum
|
||||
@resource.sha1('baadidea'*5)
|
||||
assert_equal Checksum.new(:sha1, 'baadidea'*5), @resource.checksum
|
||||
@resource.sha256('baadidea'*8)
|
||||
assert_equal Checksum.new(:sha256, 'baadidea'*8), @resource.checksum
|
||||
@resource.sha1(TEST_SHA1)
|
||||
assert_equal Checksum.new(:sha1, TEST_SHA1), @resource.checksum
|
||||
@resource.sha256(TEST_SHA256)
|
||||
assert_equal Checksum.new(:sha256, TEST_SHA256), @resource.checksum
|
||||
end
|
||||
|
||||
def test_download_strategy
|
||||
@ -104,7 +104,6 @@ class ResourceTests < Test::Unit::TestCase
|
||||
|
||||
def test_verify_download_integrity_missing
|
||||
fn = Pathname.new('test')
|
||||
checksum = @resource.sha1('baadidea'*5)
|
||||
|
||||
fn.stubs(:file? => true)
|
||||
fn.expects(:verify_checksum).raises(ChecksumMissingError)
|
||||
@ -115,7 +114,7 @@ class ResourceTests < Test::Unit::TestCase
|
||||
|
||||
def test_verify_download_integrity_mismatch
|
||||
fn = stub(:file? => true)
|
||||
checksum = @resource.sha1('baadidea'*5)
|
||||
checksum = @resource.sha1(TEST_SHA1)
|
||||
|
||||
fn.expects(:verify_checksum).with(checksum).
|
||||
raises(ChecksumMismatchError.new(checksum, Object.new))
|
||||
|
||||
@ -106,6 +106,9 @@ module Test::Unit::Assertions
|
||||
end
|
||||
|
||||
class Test::Unit::TestCase
|
||||
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
|
||||
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
|
||||
|
||||
def formula(*args, &block)
|
||||
@_f = Class.new(Formula, &block).new(*args)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user