[gnome-software: 1/2] tests: Allow progress to be unknown or 100% after flatpak installation




commit 243af75af13b0afa60a00853bfdfe9bca1eb2241
Author: Philip Withnall <pwithnall endlessos org>
Date:   Sat Dec 5 00:15:17 2020 +0000

    tests: Allow progress to be unknown or 100% after flatpak installation
    
    This might fix a flaky test in the CI, where sometimes the progress
    after installation is queried as 100%, and sometimes it’s queried as
    unknown.
    
    I think the race happens because flatpak operations (and progress
    updates) happen in another thread, and the unit test code can query at
    the point of installation being complete (seeing 100%), or once the app
    progress has been reset after installation (seeing unknown).
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Fixes: #1107

 plugins/flatpak/gs-self-test.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index ae0acda9..1f50e4ca 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -380,7 +380,8 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
        g_assert_true (ret);
        g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_INSTALLED);
        g_assert_cmpstr (gs_app_get_version (app), ==, "1.2.3");
-       g_assert_cmpint (gs_app_get_progress (app), ==, GS_APP_PROGRESS_UNKNOWN);
+       g_assert_true (gs_app_get_progress (app) == GS_APP_PROGRESS_UNKNOWN ||
+                      gs_app_get_progress (app) == 100);
        g_assert_cmpint (gs_app_get_state (runtime), ==, AS_APP_STATE_INSTALLED);
 
        /* check the application exists in the right places */
@@ -455,7 +456,8 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
        g_assert_true (ret);
        g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_INSTALLED);
        g_assert_cmpstr (gs_app_get_version (app), ==, "1.2.3");
-       g_assert_cmpint (gs_app_get_progress (app), ==, GS_APP_PROGRESS_UNKNOWN);
+       g_assert_true (gs_app_get_progress (app) == GS_APP_PROGRESS_UNKNOWN ||
+                      gs_app_get_progress (app) == 100);
        g_signal_handler_disconnect (app, signal_id);
 
        /* remove the application */
@@ -1518,7 +1520,8 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
        g_assert_cmpstr (gs_app_get_version (app), ==, "1.2.4");
        g_assert_cmpstr (gs_app_get_update_version (app), ==, NULL);
        g_assert_cmpstr (gs_app_get_update_details (app), ==, NULL);
-       g_assert_cmpint (gs_app_get_progress (app), ==, GS_APP_PROGRESS_UNKNOWN);
+       g_assert_true (gs_app_get_progress (app) == GS_APP_PROGRESS_UNKNOWN ||
+                      gs_app_get_progress (app) == 100);
        g_assert_true (got_progress_installing);
        //g_assert_cmpint (progress_cnt, >, 20); //FIXME: bug in OSTree
        g_assert_cmpint (pending_app_changed_cnt, ==, 0);


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