summaryrefslogtreecommitdiffstats
path: root/t/test_transaction.c
diff options
context:
space:
mode:
Diffstat (limited to 't/test_transaction.c')
-rw-r--r--t/test_transaction.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/t/test_transaction.c b/t/test_transaction.c
index 1e0adaa..2f11a27 100644
--- a/t/test_transaction.c
+++ b/t/test_transaction.c
@@ -7,19 +7,19 @@ START_TEST(test_transaction)
fail_if(t == NULL);
slapt_add_install_to_transaction(t, &pkg);
- fail_unless(t->install_pkgs->pkg_count == 1);
+ fail_unless(t->install_pkgs->size == 1);
fail_unless(slapt_search_transaction(t, "gslapt"));
fail_unless(slapt_search_transaction_by_pkg(t, &pkg));
t = slapt_remove_from_transaction(t, &pkg);
slapt_add_remove_to_transaction(t, &pkg);
- fail_unless(t->remove_pkgs->pkg_count == 1);
+ fail_unless(t->remove_pkgs->size == 1);
fail_unless(slapt_search_transaction(t, "gslapt"));
fail_unless(slapt_search_transaction_by_pkg(t, &pkg));
t = slapt_remove_from_transaction(t, &pkg);
slapt_add_exclude_to_transaction(t, &pkg);
- fail_unless(t->exclude_pkgs->pkg_count == 1);
+ fail_unless(t->exclude_pkgs->size == 1);
slapt_add_upgrade_to_transaction(t, &pkg, &pkg);
/* fail_unless (slapt_search_upgrade_transaction(t, &pkg)); */
@@ -46,9 +46,20 @@ END_TEST
START_TEST(test_transaction_dependencies)
{
- slapt_transaction_t *t = slapt_init_transaction();
slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ FILE *fh = fopen("data/avail_deps", "r");
+ fail_unless(fh != NULL);
+ slapt_vector_t *avail = slapt_parse_packages_txt(fh);
+ fclose(fh);
+
+ fh = fopen("data/installed_deps", "r");
+ fail_unless(fh != NULL);
+ slapt_vector_t *installed = slapt_parse_packages_txt(fh);
+ fclose(fh);
+
+ slapt_transaction_t *t = slapt_init_transaction();
+
/*
add dependencies for package to transaction, returns -1 on error, 0 otherwise
int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
@@ -71,6 +82,19 @@ START_TEST(test_transaction_dependencies)
in the transaction
void slapt_generate_suggestions(slapt_transaction_t *tran);
*/
+ slapt_pkg_info_t *p = slapt_get_newest_pkg(avail, "scim");
+ slapt_pkg_info_t *installed_p = slapt_get_newest_pkg(installed, "scim");
+ (void)installed_p;
+
+ slapt_vector_t *conflicts = slapt_is_conflicted(t, avail, installed, p);
+ if (conflicts->size > 0) {
+ slapt_add_install_to_transaction(t, conflicts->items[0]);
+ slapt_add_deps_to_trans(rc, t, avail, installed, conflicts->items[0]);
+ }
+
+ slapt_add_deps_to_trans(rc, t, avail, installed, p);
+ slapt_add_install_to_transaction(t, p);
+
slapt_generate_suggestions(t);
slapt_free_transaction(t);