END_TEST START_TEST(test_goal_selector_upgrade_provides) { DnfSack *sack = test_globals.sack; HySelector sltr = hy_selector_create(sack); HyGoal goal = hy_goal_create(sack); fail_if(hy_selector_set(sltr, HY_PKG_PROVIDES, HY_EQ, "fool")); fail_if(hy_goal_upgrade_selector(goal, sltr)); hy_selector_free(sltr); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 1, 0, 1); hy_goal_free(goal); sltr = hy_selector_create(sack); goal = hy_goal_create(sack); fail_if(hy_selector_set(sltr, HY_PKG_PROVIDES, HY_EQ, "fool > 1-3")); fail_if(hy_goal_upgrade_selector(goal, sltr)); hy_selector_free(sltr); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 1, 0, 1); hy_goal_free(goal); }
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_goal_downgrade) { HySack sack = test_globals.sack; HyPackage to_be_pkg = get_available_pkg(sack, "baby"); HyGoal goal = hy_goal_create(sack); hy_goal_downgrade_to(goal, to_be_pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 0, 0); HyPackageList plist = hy_goal_list_downgrades(goal); fail_unless(hy_packagelist_count(plist) == 1); HyPackage pkg = hy_packagelist_get(plist, 0); ck_assert_str_eq(hy_package_get_evr(pkg), "6:4.9-3"); HyPackageList obsoleted = hy_goal_list_obsoleted_by_package(goal, pkg); fail_unless(hy_packagelist_count(obsoleted) == 1); HyPackage old_pkg = hy_packagelist_get(obsoleted, 0); ck_assert_str_eq(hy_package_get_evr(old_pkg), "6:5.0-11"); hy_packagelist_free(obsoleted); hy_packagelist_free(plist); hy_goal_free(goal); hy_package_free(to_be_pkg); }
END_TEST START_TEST(test_goal_selector_upgrade) { HySelector sltr = hy_selector_create(test_globals.sack); HyGoal goal = hy_goal_create(test_globals.sack); fail_if(hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "dog")); fail_if(hy_selector_set(sltr, HY_PKG_EVR, HY_EQ, "1-2")); fail_if(hy_goal_upgrade_to_selector(goal, sltr)); fail_if(hy_goal_run(goal)); HyPackageList plist = hy_goal_list_upgrades(goal); fail_unless(hy_packagelist_count(plist) == 1); assert_nevra_eq(hy_packagelist_get(plist, 0), "dog-1-2.x86_64"); hy_packagelist_free(plist); hy_goal_free(goal); hy_selector_free(sltr); sltr = hy_selector_create(test_globals.sack); goal = hy_goal_create(test_globals.sack); fail_if(hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "pilchard")); fail_if(hy_goal_upgrade_to_selector(goal, sltr)); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 2, 0, 0); hy_goal_free(goal); hy_selector_free(sltr); }
END_TEST START_TEST(test_goal_distupgrade_all_keep_arch) { HyGoal goal = hy_goal_create(test_globals.sack); fail_if(hy_goal_distupgrade_all(goal)); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 5, 0, 1); HyPackageList plist = hy_goal_list_upgrades(goal); // gun pkg is not upgraded to latest version of different arch assert_nevra_eq(hy_packagelist_get(plist, 0), "dog-1-2.x86_64"); assert_nevra_eq(hy_packagelist_get(plist, 1), "pilchard-1.2.4-1.i686"); assert_nevra_eq(hy_packagelist_get(plist, 2), "pilchard-1.2.4-1.x86_64"); assert_nevra_eq(hy_packagelist_get(plist, 3), "flying-3.1-0.x86_64"); assert_nevra_eq(hy_packagelist_get(plist, 4), "fool-1-5.noarch"); hy_packagelist_free(plist); plist = hy_goal_list_obsoleted(goal); fail_unless(hy_packagelist_count(plist) == 1); assert_nevra_eq(hy_packagelist_get(plist, 0), "penny-4-1.noarch"); hy_packagelist_free(plist); plist = hy_goal_list_downgrades(goal); fail_unless(hy_packagelist_count(plist) == 1); assert_nevra_eq(hy_packagelist_get(plist, 0), "baby-6:4.9-3.x86_64"); hy_packagelist_free(plist); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_distupgrade_all_keep_arch) { HyGoal goal = hy_goal_create(test_globals.sack); fail_if(hy_goal_distupgrade_all(goal)); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 5, 0, 1); GPtrArray *plist = hy_goal_list_upgrades(goal, NULL); // gun pkg is not upgraded to latest version of different arch assert_nevra_eq(g_ptr_array_index(plist, 0), "dog-1-2.x86_64"); assert_nevra_eq(g_ptr_array_index(plist, 1), "pilchard-1.2.4-1.i686"); assert_nevra_eq(g_ptr_array_index(plist, 2), "pilchard-1.2.4-1.x86_64"); assert_nevra_eq(g_ptr_array_index(plist, 3), "flying-3.1-0.x86_64"); assert_nevra_eq(g_ptr_array_index(plist, 4), "fool-1-5.noarch"); g_ptr_array_unref(plist); plist = hy_goal_list_obsoleted(goal, NULL); fail_unless(plist->len == 1); assert_nevra_eq(g_ptr_array_index(plist, 0), "penny-4-1.noarch"); g_ptr_array_unref(plist); plist = hy_goal_list_downgrades(goal, NULL); fail_unless(plist->len == 1); assert_nevra_eq(g_ptr_array_index(plist, 0), "baby-6:4.9-3.x86_64"); g_ptr_array_unref(plist); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_installonly_limit_with_modules) { // most complex installonly test case, includes the k-m packages const char *installonly[] = {"k", "k-m", NULL}; HySack sack = test_globals.sack; hy_sack_set_installonly(sack, installonly); hy_sack_set_installonly_limit(sack, 3); sack->running_kernel_fn = mock_running_kernel; HyGoal goal = hy_goal_create(sack); hy_goal_upgrade_all(goal); fail_if(hy_goal_run_flags(goal, 0)); assert_iueo(goal, 2, 0, 5, 0); HyPackageList erasures = hy_goal_list_erasures(goal); assert_nevra_eq(hy_packagelist_get(erasures, 0), "k-1-0.x86_64"); assert_nevra_eq(hy_packagelist_get(erasures, 1), "k-m-1-0.x86_64"); assert_nevra_eq(hy_packagelist_get(erasures, 2), "k-freak-1-0-1-0.x86_64"); assert_nevra_eq(hy_packagelist_get(erasures, 3), "k-2-0.x86_64"); assert_nevra_eq(hy_packagelist_get(erasures, 4), "k-m-2-0.x86_64"); hy_packagelist_free(erasures); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_selector_upgrade) { HySelector sltr = hy_selector_create(test_globals.sack); HyGoal goal = hy_goal_create(test_globals.sack); fail_if(hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "dog")); fail_if(hy_selector_set(sltr, HY_PKG_EVR, HY_EQ, "1-2")); fail_if(hy_goal_upgrade_to_selector(goal, sltr)); fail_if(hy_goal_run(goal)); GPtrArray *plist = hy_goal_list_upgrades(goal, NULL); fail_unless(plist->len == 1); assert_nevra_eq(g_ptr_array_index(plist, 0), "dog-1-2.x86_64"); g_ptr_array_unref(plist); hy_goal_free(goal); hy_selector_free(sltr); sltr = hy_selector_create(test_globals.sack); goal = hy_goal_create(test_globals.sack); fail_if(hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "pilchard")); fail_if(hy_goal_upgrade_to_selector(goal, sltr)); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 2, 0, 0); hy_goal_free(goal); hy_selector_free(sltr); }
END_TEST START_TEST(test_goal_downgrade) { DnfSack *sack = test_globals.sack; DnfPackage *to_be_pkg = get_available_pkg(sack, "baby"); HyGoal goal = hy_goal_create(sack); hy_goal_downgrade_to(goal, to_be_pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 0, 0); GPtrArray *plist = hy_goal_list_downgrades(goal, NULL); fail_unless(plist->len == 1); DnfPackage *pkg = g_ptr_array_index(plist, 0); ck_assert_str_eq(dnf_package_get_evr(pkg), "6:4.9-3"); GPtrArray *obsoleted = hy_goal_list_obsoleted_by_package(goal, pkg); fail_unless(obsoleted->len == 1); DnfPackage *old_pkg = g_ptr_array_index(obsoleted, 0); ck_assert_str_eq(dnf_package_get_evr(old_pkg), "6:5.0-11"); g_ptr_array_unref(obsoleted); g_ptr_array_unref(plist); hy_goal_free(goal); g_object_unref(to_be_pkg); }
END_TEST START_TEST(test_goal_installonly_limit_with_modules) { // most complex installonly test case, includes the k-m packages const char *installonly[] = {"k", "k-m", NULL}; DnfSack *sack = test_globals.sack; dnf_sack_set_installonly(sack, installonly); dnf_sack_set_installonly_limit(sack, 3); dnf_sack_set_running_kernel_fn(sack, mock_running_kernel); HyGoal goal = hy_goal_create(sack); hy_goal_upgrade_all(goal); fail_if(hy_goal_run_flags(goal, 0)); assert_iueo(goal, 2, 0, 5, 0); GPtrArray *erasures = hy_goal_list_erasures(goal, NULL); assert_nevra_eq(g_ptr_array_index(erasures, 0), "k-1-0.x86_64"); assert_nevra_eq(g_ptr_array_index(erasures, 1), "k-m-1-0.x86_64"); assert_nevra_eq(g_ptr_array_index(erasures, 2), "k-freak-1-0-1-0.x86_64"); assert_nevra_eq(g_ptr_array_index(erasures, 3), "k-2-0.x86_64"); assert_nevra_eq(g_ptr_array_index(erasures, 4), "k-m-2-0.x86_64"); g_ptr_array_unref(erasures); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_install_weak_deps) { HySelector sltr = hy_selector_create(test_globals.sack); hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "B"); HyGoal goal = hy_goal_create(test_globals.sack); fail_if(!hy_goal_install_selector(goal, sltr, NULL)); HyGoal goal2 = hy_goal_clone(goal); fail_if(hy_goal_run(goal)); // recommended package C is installed too assert_iueo(goal, 2, 0, 0, 0); fail_if(hy_goal_run_flags(goal2, DNF_IGNORE_WEAK_DEPS)); assert_iueo(goal2, 1, 0, 0, 0); hy_goal_free(goal); hy_goal_free(goal2); hy_selector_free(sltr); }
END_TEST START_TEST(test_goal_clone) { DnfSack *sack = test_globals.sack; HyGoal goal = hy_goal_create(sack); hy_goal_upgrade_all(goal); HyGoal goal2 = hy_goal_clone(goal); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 1, 0, 0); fail_unless(size_and_free(hy_goal_list_reinstalls(goal, NULL)) == 1); hy_goal_free(goal); fail_if(hy_goal_run(goal2)); assert_iueo(goal2, 0, 1, 0, 0); fail_unless(size_and_free(hy_goal_list_reinstalls(goal2, NULL)) == 1); hy_goal_free(goal2); }
END_TEST START_TEST(test_cmdline_file_provides) { HySack sack = test_globals.sack; HyGoal goal = hy_goal_create(sack); hy_goal_upgrade_all(goal); ck_assert(!hy_goal_run_flags(goal, HY_FORCE_BEST)); assert_iueo(goal, 0, 1, 0, 0); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_install) { DnfPackage *pkg = get_latest_pkg(test_globals.sack, "walrus"); HyGoal goal = hy_goal_create(test_globals.sack); fail_if(hy_goal_install(goal, pkg)); g_object_unref(pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 2, 0, 0, 0); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_upgrade) { DnfPackage *pkg = get_latest_pkg(test_globals.sack, "fool"); HyGoal goal = hy_goal_create(test_globals.sack); fail_if(hy_goal_upgrade_to_flags(goal, pkg, HY_CHECK_INSTALLED)); g_object_unref(pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 1, 0, 1); hy_goal_free(goal); }
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); }
END_TEST START_TEST(test_cmdline_file_provides) { DnfSack *sack = test_globals.sack; dnf_sack_set_running_kernel_fn(sack, mock_running_kernel_no); HyGoal goal = hy_goal_create(sack); hy_goal_upgrade_all(goal); ck_assert(!hy_goal_run_flags(goal, DNF_FORCE_BEST)); assert_iueo(goal, 0, 1, 0, 0); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_no_reinstall) { HySack sack = test_globals.sack; HyPackage pkg = get_latest_pkg(sack, "penny"); HyGoal goal = hy_goal_create(sack); fail_if(hy_goal_install(goal, pkg)); hy_package_free(pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 0, 0); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_no_reinstall) { DnfSack *sack = test_globals.sack; DnfPackage *pkg = get_latest_pkg(sack, "penny"); HyGoal goal = hy_goal_create(sack); fail_if(hy_goal_install(goal, pkg)); g_object_unref(pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 0, 0); hy_goal_free(goal); }
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_install_optional) { HySelector sltr; HyGoal goal = hy_goal_create(test_globals.sack); // test optional selector installation sltr = hy_selector_create(test_globals.sack); hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "hello"); fail_if(!hy_goal_install_selector_optional(goal, sltr, NULL)); fail_if(hy_goal_run(goal)); hy_selector_free(sltr); assert_iueo(goal, 0, 0, 0, 0); // test optional package installation DnfPackage *pkg = get_latest_pkg(test_globals.sack, "hello"); fail_if(hy_goal_install_optional(goal, pkg)); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 0, 0); g_object_unref(pkg); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_selector_glob) { HySelector sltr = hy_selector_create(test_globals.sack); HyGoal goal = hy_goal_create(test_globals.sack); fail_if(hy_selector_set(sltr, HY_PKG_NAME, HY_GLOB, "*emolin*")); fail_if(!hy_goal_install_selector(goal, sltr, NULL)); fail_if(hy_goal_run(goal)); assert_iueo(goal, 1, 0, 0, 0); hy_goal_free(goal); hy_selector_free(sltr); }
END_TEST START_TEST(test_goal_install_selector_nomatch) { HySelector sltr = hy_selector_create(test_globals.sack); HyGoal goal = hy_goal_create(test_globals.sack); hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "crabalocker"); fail_if(!hy_goal_install_selector(goal, sltr, NULL)); hy_selector_free(sltr); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 0, 0); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_selector_provides_glob) { HySelector sltr = hy_selector_create(test_globals.sack); HyGoal goal = hy_goal_create(test_globals.sack); fail_if(hy_selector_set(sltr, HY_PKG_PROVIDES, HY_GLOB, "P*")); fail_if(hy_goal_erase_selector(goal, sltr)); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 1, 0); hy_goal_free(goal); hy_selector_free(sltr); }
END_TEST START_TEST(test_goal_forcebest_arches) { DnfSack *sack = test_globals.sack; HyGoal goal = hy_goal_create(sack); HySelector sltr = hy_selector_create(sack); hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "gun"); fail_if(hy_goal_upgrade_selector(goal, sltr)); fail_if(hy_goal_run_flags(goal, DNF_FORCE_BEST)); assert_iueo(goal, 0, 0, 0, 0); hy_selector_free(sltr); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_change) { // test that changes are handled like reinstalls DnfSack *sack = test_globals.sack; HyGoal goal = hy_goal_create(sack); hy_goal_upgrade_all(goal); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 1, 0, 0); fail_unless(size_and_free(hy_goal_list_reinstalls(goal, NULL)) == 1); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_installonly) { const char *installonly[] = {"fool", NULL}; DnfSack *sack = test_globals.sack; dnf_sack_set_installonly(sack, installonly); dnf_sack_set_installonly_limit(sack, 2); DnfPackage *pkg = get_latest_pkg(sack, "fool"); HyGoal goal = hy_goal_create(sack); fail_if(hy_goal_upgrade_to_flags(goal, pkg, HY_CHECK_INSTALLED)); g_object_unref(pkg); fail_if(hy_goal_run(goal)); assert_iueo(goal, 1, 0, 1, 0); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_install_multilib) { // Tests installation of multilib package. The package is selected via // install query, allowing the depsolver maximum influence on the selection. HySelector sltr = hy_selector_create(test_globals.sack); HyGoal goal = hy_goal_create(test_globals.sack); hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "semolina"); fail_if(!hy_goal_install_selector(goal, sltr, NULL)); fail_if(hy_goal_run(goal)); assert_iueo(goal, 1, 0, 0, 0); hy_selector_free(sltr); hy_goal_free(goal); }
END_TEST START_TEST(test_goal_distupgrade_selector_nothing) { HyGoal goal = hy_goal_create(test_globals.sack); HySelector sltr = hy_selector_create(test_globals.sack); hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "P-lib"); fail_if(hy_goal_distupgrade_selector(goal, sltr)); fail_if(hy_goal_run(goal)); assert_iueo(goal, 0, 0, 0, 0); GPtrArray *plist = hy_goal_list_downgrades(goal, NULL); fail_unless(plist->len == 0); g_ptr_array_unref(plist); hy_goal_free(goal); hy_selector_free(sltr); }