[gnome-software: 71/72] tests: Use correct result lists when checking wildcard resolves




commit 8de30ecffcaf479226b1b127fa09515d99a35041
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Dec 8 10:55:52 2021 +0000

    tests: Use correct result lists when checking wildcard resolves
    
    Since the introduction of `GsPluginJobRefine`, the original `GsAppList`
    passed as an argument to the job is no longer modified, and the results
    are returned as a separate list. This move towards treating lists as
    more immutable should make it easier to keep things threadsafe in
    future.
    
    `gs_plugin_loader_job_process_finish()` already handles that and returns
    the results list, so most code doesn’t need changes. However, these
    tests are using a wrapper which doesn’t return a result list at all. So
    they need modifying to explicitly check the correct list.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 plugins/core/gs-self-test.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/plugins/core/gs-self-test.c b/plugins/core/gs-self-test.c
index 0064766d3..1830638ca 100644
--- a/plugins/core/gs-self-test.c
+++ b/plugins/core/gs-self-test.c
@@ -111,6 +111,8 @@ gs_plugins_core_generic_updates_func (GsPluginLoader *plugin_loader)
        g_autoptr(GsApp) app_wildcard = NULL;
        g_autoptr(GsAppList) list = NULL;
        g_autoptr(GsAppList) list_wildcard = NULL;
+       GsAppList *result_list;
+       GsAppList *result_list_wildcard;
 
        /* drop all caches */
        gs_utils_rmtree (g_getenv ("GS_SELF_TEST_CACHEDIR"), NULL);
@@ -141,8 +143,9 @@ gs_plugins_core_generic_updates_func (GsPluginLoader *plugin_loader)
        g_assert_true (ret);
 
        /* make sure there is one entry, the os update */
-       g_assert_cmpint (gs_app_list_length (list), ==, 1);
-       os_update = gs_app_list_index (list, 0);
+       result_list = gs_plugin_job_refine_get_result_list (GS_PLUGIN_JOB_REFINE (plugin_job));
+       g_assert_cmpint (gs_app_list_length (result_list), ==, 1);
+       os_update = gs_app_list_index (result_list, 0);
 
        /* make sure the os update is valid */
        g_assert_cmpstr (gs_app_get_id (os_update), ==, "org.gnome.Software.OsUpdate");
@@ -165,10 +168,11 @@ gs_plugins_core_generic_updates_func (GsPluginLoader *plugin_loader)
        gs_test_flush_main_context ();
        g_assert_no_error (error);
        g_assert_true (ret);
+       result_list_wildcard = gs_plugin_job_refine_get_result_list (GS_PLUGIN_JOB_REFINE (plugin_job2));
 
        /* no OsUpdate item created */
-       for (guint i = 0; i < gs_app_list_length (list_wildcard); i++) {
-               GsApp *app_tmp = gs_app_list_index (list_wildcard, i);
+       for (guint i = 0; i < gs_app_list_length (result_list_wildcard); i++) {
+               GsApp *app_tmp = gs_app_list_index (result_list_wildcard, i);
                g_assert_cmpint (gs_app_get_kind (app_tmp), !=, AS_COMPONENT_KIND_GENERIC);
                g_assert_cmpint (gs_app_get_special_kind (app_tmp), !=, GS_APP_SPECIAL_KIND_OS_UPDATE);
                g_assert_false (gs_app_has_quirk (app_tmp, GS_APP_QUIRK_IS_PROXY));


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