[evolution-data-server/openismus-work-master: 10/12] Improving test-client-remove-contact



commit 5ccb897104ceef515fb66b21704f8131b43adcb7
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Mon Jan 21 17:35:13 2013 +0900

    Improving test-client-remove-contact
    
    Check for error type is more clear and safe now.

 tests/libebook/client/test-client-remove-contact.c |   31 ++++++++++++-------
 1 files changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/tests/libebook/client/test-client-remove-contact.c b/tests/libebook/client/test-client-remove-contact.c
index 2649f09..bb314aa 100644
--- a/tests/libebook/client/test-client-remove-contact.c
+++ b/tests/libebook/client/test-client-remove-contact.c
@@ -8,12 +8,28 @@
 static ETestServerClosure book_closure = { E_TEST_SERVER_ADDRESS_BOOK, NULL, 0 };
 
 static void
+check_removed_contact (EBookClient *book_client,
+		       const gchar *uid)
+{
+	GError *error = NULL;
+	EContact *contact = NULL;
+
+	if (e_book_client_get_contact_sync (book_client, uid, &contact, NULL, &error))
+		g_error ("succeeded to fetch removed contact");
+	else if (!g_error_matches (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND))
+		g_error ("Wrong error in get contact sync on removed contact: %s (domain: %s, code: %d)",
+			 error->message, g_quark_to_string (error->domain), error->code);
+	else
+		g_clear_error (&error);
+}
+
+static void
 test_remove_contact_sync (ETestServerFixture *fixture,
                           gconstpointer user_data)
 {
 	EBookClient *book_client;
 	GError *error = NULL;
-	EContact *contact;
+	EContact *contact = NULL;
 	gchar *uid;
 
 	book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient);
@@ -28,11 +44,7 @@ test_remove_contact_sync (ETestServerFixture *fixture,
 
 	g_object_unref (contact);
 
-	if (!e_book_client_get_contact_sync (book_client, uid, &contact, NULL, &error) &&
-	    g_error_matches (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND)) {
-		g_clear_error (&error);
-	} else
-		g_error ("fail with get contact sync on removed contact: %s", error->message);
+	check_removed_contact (book_client, uid);
 
 	g_free (uid);
 }
@@ -49,16 +61,11 @@ remove_contact_cb (GObject *source_object,
 {
 	RemoveData *data = (RemoveData *) user_data;
 	GError *error = NULL;
-	EContact *contact = NULL;
 
 	if (!e_book_client_remove_contact_finish (E_BOOK_CLIENT (source_object), result, &error))
 		g_error ("remove contact finish: %s", error->message);
 
-	if (!e_book_client_get_contact_sync (E_BOOK_CLIENT (source_object), data->uid, &contact, NULL, &error) &&
-	    g_error_matches (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND)) {
-		g_clear_error (&error);
-	} else
-		g_error ("fail with get contact on removed contact: %s", error->message);
+	check_removed_contact (E_BOOK_CLIENT (source_object), data->uid);
 
 	g_main_loop_quit (data->loop);
 }



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