[gnome-software/wip/hughsie/no-claim-wildcard] trivial: Fix a typo when checking lists for duplicates



commit a0e108238f80e63975316f0fc271013e2207a88c
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jul 16 09:51:15 2019 +0100

    trivial: Fix a typo when checking lists for duplicates

 lib/gs-app-list.c  |  2 +-
 lib/gs-self-test.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-app-list.c b/lib/gs-app-list.c
index 0acf7fe5..f8732dd6 100644
--- a/lib/gs-app-list.c
+++ b/lib/gs-app-list.c
@@ -293,7 +293,7 @@ gs_app_list_check_for_duplicate (GsAppList *list, GsApp *app)
        if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD)) {
                for (guint i = 0; i < list->array->len; i++) {
                        GsApp *app_tmp = g_ptr_array_index (list->array, i);
-                       if (!gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
+                       if (!gs_app_has_quirk (app_tmp, GS_APP_QUIRK_IS_WILDCARD))
                                continue;
                        /* not adding exactly the same wildcard */
                        if (g_strcmp0 (gs_app_get_unique_id (app_tmp),
diff --git a/lib/gs-self-test.c b/lib/gs-self-test.c
index 01efeca1..8360e06b 100644
--- a/lib/gs-self-test.c
+++ b/lib/gs-self-test.c
@@ -693,6 +693,20 @@ gs_app_func (void)
        gs_app_set_state_recover (app);
 }
 
+static void
+gs_app_list_wildcard_dedupe_func (void)
+{
+       g_autoptr(GsAppList) list = gs_app_list_new ();
+       g_autoptr(GsApp) app1 = gs_app_new ("app");
+       g_autoptr(GsApp) app2 = gs_app_new ("app");
+
+       gs_app_add_quirk (app1, GS_APP_QUIRK_IS_WILDCARD);
+       gs_app_list_add (list, app1);
+       gs_app_add_quirk (app2, GS_APP_QUIRK_IS_WILDCARD);
+       gs_app_list_add (list, app2);
+       g_assert_cmpint (gs_app_list_length (list), ==, 1);
+}
+
 static void
 gs_app_list_func (void)
 {
@@ -766,6 +780,7 @@ main (int argc, char **argv)
        g_test_add_func ("/gnome-software/lib/app{unique-id}", gs_app_unique_id_func);
        g_test_add_func ("/gnome-software/lib/app{thread}", gs_app_thread_func);
        g_test_add_func ("/gnome-software/lib/app{list}", gs_app_list_func);
+       g_test_add_func ("/gnome-software/lib/app{list-wildcard-dedupe}", gs_app_list_wildcard_dedupe_func);
        g_test_add_func ("/gnome-software/lib/app{list-related}", gs_app_list_related_func);
        g_test_add_func ("/gnome-software/lib/plugin", gs_plugin_func);
        g_test_add_func ("/gnome-software/lib/plugin{download-rewrite}", gs_plugin_download_rewrite_func);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]