more unit tests
Closes Homebrew/homebrew#42096. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
parent
a675aae553
commit
ca1f5dc713
27
Library/Homebrew/test/test_caveats.rb
Normal file
27
Library/Homebrew/test/test_caveats.rb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
require 'testing_env'
|
||||||
|
|
||||||
|
class CaveatsTests < Homebrew::TestCase
|
||||||
|
def setup
|
||||||
|
@f = formula { url "foo-1.0" }
|
||||||
|
@c = Caveats.new @f
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_f
|
||||||
|
assert_equal @f, @c.f
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_empty?
|
||||||
|
assert @c.empty?
|
||||||
|
|
||||||
|
f = formula do
|
||||||
|
url "foo-1.0"
|
||||||
|
|
||||||
|
def caveats
|
||||||
|
"something"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
c = Caveats.new f
|
||||||
|
|
||||||
|
refute c.empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -71,6 +71,20 @@ class DependenciesTests < Homebrew::TestCase
|
|||||||
refute_equal a, b
|
refute_equal a, b
|
||||||
refute_eql a, b
|
refute_eql a, b
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_empty
|
||||||
|
a = Dependencies.new
|
||||||
|
assert a.empty?
|
||||||
|
a << Dependency.new("foo")
|
||||||
|
refute a.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_inspect
|
||||||
|
a = Dependencies.new
|
||||||
|
assert_equal "#<Dependencies: []>", a.inspect
|
||||||
|
a << Dependency.new("foo")
|
||||||
|
assert_equal "#<Dependencies: [#<Dependency: \"foo\" []>]>", a.inspect
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RequirementsTests < Homebrew::TestCase
|
class RequirementsTests < Homebrew::TestCase
|
||||||
|
|||||||
@ -257,4 +257,28 @@ class FormulaTests < Homebrew::TestCase
|
|||||||
assert f.option_defined?("bar")
|
assert f.option_defined?("bar")
|
||||||
assert f.option_defined?("baz")
|
assert f.option_defined?("baz")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_desc
|
||||||
|
f = formula do
|
||||||
|
desc "a formula"
|
||||||
|
url "foo-1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "a formula", f.desc
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_post_install_defined
|
||||||
|
f1 = formula do
|
||||||
|
url "foo-1.0"
|
||||||
|
|
||||||
|
def post_install;end
|
||||||
|
end
|
||||||
|
|
||||||
|
f2 = formula do
|
||||||
|
url "foo-1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
assert f1.post_install_defined?
|
||||||
|
refute f2.post_install_defined?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,6 +23,10 @@ class OptionTests < Homebrew::TestCase
|
|||||||
assert_empty @option.description
|
assert_empty @option.description
|
||||||
assert_equal "foo", Option.new("foo", "foo").description
|
assert_equal "foo", Option.new("foo", "foo").description
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_inspect
|
||||||
|
assert_equal "#<Option: \"--foo\">", @option.inspect
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class DeprecatedOptionTests < Homebrew::TestCase
|
class DeprecatedOptionTests < Homebrew::TestCase
|
||||||
@ -121,10 +125,21 @@ class OptionsTests < Homebrew::TestCase
|
|||||||
assert_equal [foo, bar, baz].sort, (@options | options).sort
|
assert_equal [foo, bar, baz].sort, (@options | options).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_times
|
||||||
|
@options << Option.new("aa") << Option.new("bb") << Option.new("cc")
|
||||||
|
assert_equal %w[--aa --bb --cc], (@options * "XX").split("XX").sort
|
||||||
|
end
|
||||||
|
|
||||||
def test_create_with_array
|
def test_create_with_array
|
||||||
array = %w{--foo --bar}
|
array = %w{--foo --bar}
|
||||||
option1 = Option.new("foo")
|
option1 = Option.new("foo")
|
||||||
option2 = Option.new("bar")
|
option2 = Option.new("bar")
|
||||||
assert_equal [option1, option2].sort, Options.create(array).sort
|
assert_equal [option1, option2].sort, Options.create(array).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_inspect
|
||||||
|
assert_equal "#<Options: []>", @options.inspect
|
||||||
|
@options << Option.new("foo")
|
||||||
|
assert_equal "#<Options: [#<Option: \"--foo\">]>", @options.inspect
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -44,4 +44,10 @@ class MacOSVersionTests < Homebrew::TestCase
|
|||||||
assert_equal @v, MacOS::Version.from_symbol(:lion)
|
assert_equal @v, MacOS::Version.from_symbol(:lion)
|
||||||
assert_raises(ArgumentError) { MacOS::Version.from_symbol(:foo) }
|
assert_raises(ArgumentError) { MacOS::Version.from_symbol(:foo) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_pretty_name
|
||||||
|
assert_equal "El Capitan", MacOS::Version.new("10.11").pretty_name
|
||||||
|
assert_equal "Mountain Lion", MacOS::Version.new("10.8").pretty_name
|
||||||
|
assert_equal "Yosemite", MacOS::Version.new("10.10").pretty_name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user