Skip to content
Snippets Groups Projects
Commit 4d11def5 authored by Jack Nagel's avatar Jack Nagel
Browse files

Add tests documenting install receipt loading behavior

parent 34db1bd1
No related branches found
No related tags found
No related merge requests found
require "testing_env"
require "tab"
require "formula"
class TabTests < Homebrew::TestCase
def setup
......@@ -85,3 +86,60 @@ class TabTests < Homebrew::TestCase
assert_equal :libcxx, tab.cxxstdlib.type
end
end
class TabLoadingTests < Homebrew::TestCase
def setup
@f = formula { url "foo-1.0" }
@f.prefix.mkpath
@path = @f.prefix.join(Tab::FILENAME)
@path.write Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt.json").read
@path = @path.realpath
end
def teardown
@f.rack.rmtree
end
def test_for_keg
tab = Tab.for_keg(@f.prefix)
assert_equal @path, tab.tabfile
end
def test_for_keg_nonexistent_path
@path.unlink
tab = Tab.for_keg(@f.prefix)
assert_nil tab.tabfile
end
def test_for_formula
tab = Tab.for_formula(@f)
assert_equal @path, tab.tabfile
end
def test_for_formula_nonexistent_path
@path.unlink
tab = Tab.for_formula(@f)
assert_nil tab.tabfile
end
def test_for_formula_multiple_kegs
f2 = formula { url "foo-2.0" }
f2.prefix.mkpath
assert_equal @f.rack, f2.rack
assert_equal 2, @f.rack.subdirs.length
tab = Tab.for_formula(@f)
assert_equal @path, tab.tabfile
end
def test_for_formula_outdated_keg
f2 = formula { url "foo-2.0" }
assert_equal @f.rack, f2.rack
assert_equal 1, @f.rack.subdirs.length
tab = Tab.for_formula(f2)
assert_equal @path, tab.tabfile
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment