END_TEST START_TEST(test_goal_erase_clean_deps) { DnfSack *sack = test_globals.sack; DnfPackage *pkg = by_name_repo(sack, "flying", HY_SYSTEM_REPO_NAME); // by default, leave dependencies alone: HyGoal goal = hy_goal_create(sack); hy_goal_erase(goal, pkg); hy_goal_run(goal); assert_iueo(goal, 0, 0, 1, 0); hy_goal_free(goal); // allow deleting dependencies: goal = hy_goal_create(sack); hy_goal_erase_flags(goal, pkg, HY_CLEAN_DEPS); fail_unless(hy_goal_run(goal) == 0); assert_iueo(goal, 0, 0, 2, 0); hy_goal_free(goal); // test userinstalled specification: DnfPackage *penny_pkg = by_name_repo(sack, "penny-lib", HY_SYSTEM_REPO_NAME); goal = hy_goal_create(sack); hy_goal_erase_flags(goal, pkg, HY_CLEAN_DEPS); hy_goal_userinstalled(goal, penny_pkg); // having the same solvable twice in a goal shouldn't break anything: hy_goal_userinstalled(goal, pkg); fail_unless(hy_goal_run(goal) == 0); assert_iueo(goal, 0, 0, 1, 0); hy_goal_free(goal); g_object_unref(penny_pkg); g_object_unref(pkg); }
END_TEST START_TEST(test_installed) { HyPackage pkg1 = by_name_repo(test_globals.sack, "penny-lib", "main"); HyPackage pkg2 = by_name_repo(test_globals.sack, "penny-lib", HY_SYSTEM_REPO_NAME); int installed1 = hy_package_installed(pkg1); int installed2 = hy_package_installed(pkg2); fail_unless(installed1 == 0); fail_unless(installed2 == 1); hy_package_free(pkg1); hy_package_free(pkg2); }
END_TEST START_TEST(test_goal_protected) { DnfSack *sack = test_globals.sack; DnfPackageSet *protected = dnf_packageset_new(sack); DnfPackage *pkg = by_name_repo(sack, "penny-lib", HY_SYSTEM_REPO_NAME); DnfPackage *pp = by_name_repo(sack, "flying", HY_SYSTEM_REPO_NAME); const char *expected; g_autofree gchar *problem; // when protected_packages set is empty it should remove both packages HyGoal goal = hy_goal_create(sack); DnfPackageSet *empty = dnf_packageset_new(sack); dnf_goal_set_protected(goal, empty); g_object_unref(empty); hy_goal_erase(goal, pkg); fail_if(hy_goal_run_flags(goal, DNF_ALLOW_UNINSTALL)); assert_iueo(goal, 0, 0, 2, 0); hy_goal_free(goal); // fails to uninstall penny-lib because flying is protected goal = hy_goal_create(sack); dnf_packageset_add(protected, pp); dnf_goal_set_protected(goal, protected); hy_goal_erase(goal, pkg); fail_unless(hy_goal_run_flags(goal, DNF_ALLOW_UNINSTALL)); hy_goal_free(goal); // removal of protected package explicitly should trigger error goal = hy_goal_create(sack); dnf_goal_set_protected(goal, protected); hy_goal_erase(goal, pp); fail_unless(hy_goal_run(goal)); fail_unless(hy_goal_count_problems(goal) == 1); problem = hy_goal_describe_problem(goal, 0); expected = "The operation would result in removing " "the following protected packages: flying"; fail_if(g_strcmp0(problem, expected)); hy_goal_free(goal); g_object_unref(protected); g_object_unref(pkg); g_object_unref(pp); }
END_TEST START_TEST(test_goal_erase_simple) { DnfSack *sack = test_globals.sack; DnfPackage *pkg = by_name_repo(sack, "penny", HY_SYSTEM_REPO_NAME); HyGoal goal = hy_goal_create(sack); fail_if(hy_goal_erase(goal, pkg)); g_object_unref(pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 1, 0); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_erase_simple) { HySack sack = test_globals.sack; HyPackage pkg = by_name_repo(sack, "penny", HY_SYSTEM_REPO_NAME); HyGoal goal = hy_goal_create(sack); fail_if(hy_goal_erase(goal, pkg)); hy_package_free(pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 1, 0); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_erase_with_deps) { DnfSack *sack = test_globals.sack; DnfPackage *pkg = by_name_repo(sack, "penny-lib", HY_SYSTEM_REPO_NAME); // by default can not remove penny-lib, flying depends on it: HyGoal goal = hy_goal_create(sack); hy_goal_erase(goal, pkg); fail_unless(hy_goal_run(goal)); hy_goal_free(goal); goal = hy_goal_create(sack); hy_goal_erase(goal, pkg); fail_if(hy_goal_run_flags(goal, DNF_ALLOW_UNINSTALL)); assert_iueo(goal, 0, 0, 2, 0); hy_goal_free(goal); g_object_unref(pkg); }
END_TEST START_TEST(test_goal_rerun) { DnfSack *sack = test_globals.sack; HyGoal goal = hy_goal_create(sack); DnfPackage *pkg = get_latest_pkg(sack, "walrus"); hy_goal_install(goal, pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 2, 0, 0, 0); g_object_unref(pkg); // add an erase: pkg = by_name_repo(sack, "dog", HY_SYSTEM_REPO_NAME); hy_goal_erase(goal, pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 2, 0, 1, 0); g_object_unref(pkg); hy_goal_free(goal); }