[evolution-data-server/openismus-work-3-8: 13/116] test-server-utils: Allow reuse of existing addressbook.



commit 78a8797cf626982e77fa825cd8f93041765a3089
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Fri Apr 19 19:48:08 2013 +0900

    test-server-utils: Allow reuse of existing addressbook.
    
    If committing the new scratch source ends with an error that
    the addressbook/calendar already exists, then just use the existing
    source instead of bailing out.
    
    This is needed for tests which reuse the addressbook from a previous test.
    
    Conflicts:
    
        tests/test-server-utils/e-test-server-utils.c

 tests/test-server-utils/e-test-server-utils.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/tests/test-server-utils/e-test-server-utils.c b/tests/test-server-utils/e-test-server-utils.c
index d1721e5..0de33cc 100644
--- a/tests/test-server-utils/e-test-server-utils.c
+++ b/tests/test-server-utils/e-test-server-utils.c
@@ -280,8 +280,24 @@ e_test_server_utils_bootstrap_idle (FixturePair *pair)
                if (pair->closure->customize)
                        pair->closure->customize (scratch, pair->closure);
 
-               if (!e_source_registry_commit_source_sync (pair->fixture->registry, scratch, NULL, &error))
-                       g_error ("Unable to add new addressbook source to the registry: %s", error->message);
+               if (!e_source_registry_commit_source_sync (pair->fixture->registry, scratch, NULL, &error)) {
+                       /* Allow sources to carry from one test to the next, if the keep_work_directory
+                        * semantics are used then that's what we want (to reuse a source from the
+                        * previous test case).
+                        */
+                       if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
+                               ESource *source = e_source_registry_ref_source (pair->fixture->registry,
+                                                                               pair->fixture->source_name);
+
+                               g_clear_error (&error);
+
+                               g_assert (E_IS_SOURCE (source));
+
+                               e_test_server_utils_source_added (pair->fixture->registry, source, pair);
+                               g_object_unref (source);
+                       } else
+                               g_error ("Unable to add new addressbook source to the registry: %s", 
error->message);
+               }
 
                g_object_unref (scratch);
        }


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