Skip to content

Commit

Permalink
test_formula: add migration_needed test
Browse files Browse the repository at this point in the history
  • Loading branch information
vladshablinsky authored and xu-cheng committed Jun 29, 2016
1 parent 9c15174 commit 0d3b5f6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Library/Homebrew/test/test_formula.rb
Expand Up @@ -40,6 +40,28 @@ def test_any_version_installed?
f.rack.rmtree
end

def test_migration_needed
f = Testball.new("newname")
f.instance_variable_set(:@oldname, "oldname")
f.instance_variable_set(:@tap, CoreTap.instance)

oldname_prefix = HOMEBREW_CELLAR/"oldname/2.20"
oldname_prefix.mkpath
oldname_tab = Tab.empty
oldname_tab.tabfile = oldname_prefix.join("INSTALL_RECEIPT.json")
oldname_tab.write

refute_predicate f, :migration_needed?

oldname_tab.tabfile.unlink
oldname_tab.source["tap"] = "homebrew/core"
oldname_tab.write

assert_predicate f, :migration_needed?
ensure
oldname_prefix.parent.rmtree
end

def test_installed?
f = Testball.new
f.stubs(:installed_prefix).returns(stub(:directory? => false))
Expand Down

0 comments on commit 0d3b5f6

Please sign in to comment.