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