Skip to content
Snippets Groups Projects
Commit bb30b01d authored by Alyssa Ross's avatar Alyssa Ross
Browse files

uninstall: go easier on the integration tests

parent 3702e561
No related branches found
No related tags found
No related merge requests found
......@@ -116,7 +116,7 @@ class Keg
next unless required.any?
required_kegs = required.map { |f| kegs_by_name[f].sort_by(&:version).last }
return required_kegs, [dependent]
return required_kegs, [dependent.to_s]
end
nil
......
......@@ -332,31 +332,54 @@ class InstalledDependantsTests < LinkTests
@dependent = setup_test_keg("bar", "1.0")
end
def dependencies(deps)
tab = Tab.for_keg(@dependent)
tab.tabfile = @dependent.join("INSTALL_RECEIPT.json")
tab.runtime_dependencies = deps
def alter_tab(keg = @dependent)
tab = Tab.for_keg(keg)
yield tab
tab.write
end
def test_no_dependencies
def dependencies(deps)
alter_tab do |tab|
tab.tabfile = @dependent.join("INSTALL_RECEIPT.json")
tab.runtime_dependencies = deps
end
end
def test_no_dependencies_anywhere
dependencies nil
assert_empty @keg.installed_dependents
assert_nil Keg.find_some_installed_dependents([@keg])
end
def test_missing_formula_dependency
dependencies nil
Formula["bar"].class.depends_on "foo"
assert_empty @keg.installed_dependents
assert_equal [[@keg], ["bar"]], Keg.find_some_installed_dependents([@keg])
end
def test_empty_dependencies_in_tab
dependencies []
assert_empty @keg.installed_dependents
assert_nil Keg.find_some_installed_dependents([@keg])
end
def test_same_name_different_version
def test_same_name_different_version_in_tab
dependencies [{ "full_name" => "foo", "version" => "1.1" }]
assert_empty @keg.installed_dependents
assert_nil Keg.find_some_installed_dependents([@keg])
end
def test_different_name_same_version
def test_different_name_same_version_in_tab
stub_formula_name("baz")
dependencies [{ "full_name" => "baz", "version" => @keg.version.to_s }]
assert_empty @keg.installed_dependents
assert_nil Keg.find_some_installed_dependents([@keg])
end
def test_same_name_and_version
def test_same_name_and_version_in_tab
dependencies [{ "full_name" => "foo", "version" => "1.0" }]
assert_equal [@dependent], @keg.installed_dependents
assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg])
end
end
......@@ -48,110 +48,21 @@ class IntegrationCommandTestUninstall < IntegrationCommandTestCase
end
def test_uninstall
cmd("install", testball)
assert_match "Uninstalling testball", cmd("uninstall", "--force", testball)
assert_empty Formulary.factory(testball).installed_kegs
end
def test_uninstall_with_unrelated_missing_deps_in_tab
setup_test_formula "testball"
run_as_not_developer do
cmd("install", testball)
cmd("install", "testball_f2")
cmd("uninstall", "--ignore-dependencies", "testball_f1")
cmd("uninstall", testball)
end
end
def test_uninstall_with_unrelated_missing_deps_not_in_tab
setup_test_formula "testball"
run_as_not_developer do
cmd("install", testball)
cmd("install", "testball_f2")
f2_keg = f2.installed_kegs.first
f2_tab = Tab.for_keg(f2_keg)
f2_tab.runtime_dependencies = nil
f2_tab.write
cmd("uninstall", "--ignore-dependencies", "testball_f1")
cmd("uninstall", testball)
end
end
def test_uninstall_leaving_dependents
cmd("install", "testball_f2")
run_as_not_developer do
assert_match "Refusing to uninstall",
cmd_fail("uninstall", "testball_f1")
refute_empty f1.installed_kegs
assert_match "Uninstalling #{f2.rack}",
cmd("uninstall", "testball_f2")
assert_empty f2.installed_kegs
end
end
def test_uninstall_leaving_dependents_no_runtime_dependencies_in_tab
cmd("install", "testball_f2")
f2_keg = f2.installed_kegs.first
f2_tab = Tab.for_keg(f2_keg)
f2_tab.runtime_dependencies = nil
f2_tab.write
run_as_not_developer do
assert_match "Refusing to uninstall",
cmd_fail("uninstall", "testball_f1")
refute_empty f1.installed_kegs
assert_match "Uninstalling #{f2.rack}",
cmd("uninstall", "testball_f2")
assert_empty f2.installed_kegs
end
end
def test_uninstall_force_leaving_dependents
cmd("install", "testball_f2")
run_as_not_developer do
assert_match "Refusing to uninstall",
cmd_fail("uninstall", "testball_f1", "--force")
refute_empty f1.installed_kegs
assert_match "Uninstalling testball_f2",
cmd("uninstall", "testball_f2", "--force")
assert_empty f2.installed_kegs
end
end
def test_uninstall_ignore_dependencies_leaving_dependents
cmd("install", "testball_f2")
run_as_not_developer do
assert_match "Uninstalling #{f1.rack}",
cmd("uninstall", "testball_f1", "--ignore-dependencies")
assert_empty f1.installed_kegs
end
end
def test_uninstall_leaving_dependents_developer
cmd("install", "testball_f2")
assert_match "Uninstalling #{f1.rack}",
cmd("uninstall", "testball_f1")
assert_empty f1.installed_kegs
end
def test_uninstall_dependent_first
cmd("install", "testball_f2")
run_as_not_developer do
assert_match "Uninstalling #{f1.rack}",
cmd("uninstall", "testball_f2", "testball_f1")
cmd("uninstall", "testball_f1")
assert_empty f1.installed_kegs
end
end
def test_uninstall_dependent_last
cmd("install", "testball_f2")
run_as_not_developer do
assert_match "Uninstalling #{f2.rack}",
cmd("uninstall", "testball_f1", "testball_f2")
assert_empty f2.installed_kegs
end
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