[evolution-data-server/openismus-work] test-client-remove-contact.c: Enhanced test case



commit 53b9af4790cdb7145abc5f6e430d424b3608e45c
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Fri Feb 22 18:31:59 2013 +0900

    test-client-remove-contact.c: Enhanced test case
    
    Check that removing a removed contact reports the correct error code

 tests/libebook/client/test-client-remove-contact.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/tests/libebook/client/test-client-remove-contact.c 
b/tests/libebook/client/test-client-remove-contact.c
index 43d947a..f9cd149 100644
--- a/tests/libebook/client/test-client-remove-contact.c
+++ b/tests/libebook/client/test-client-remove-contact.c
@@ -1,11 +1,13 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
+#include <locale.h>
 #include <libebook/libebook.h>
 
 #include "client-test-utils.h"
 #include "e-test-server-utils.h"
 
 static ETestServerClosure book_closure = { E_TEST_SERVER_ADDRESS_BOOK, NULL, 0 };
+static ETestServerClosure direct_book_closure = { E_TEST_SERVER_DIRECT_ADDRESS_BOOK, NULL, 0 };
 
 static void
 check_removed_contact (EBookClient *book_client,
@@ -21,6 +23,14 @@ check_removed_contact (EBookClient *book_client,
                         error->message, g_quark_to_string (error->domain), error->code);
        else
                g_clear_error (&error);
+
+       if (e_book_client_remove_contact_by_uid_sync (book_client, uid, NULL, &error))
+               g_error ("succeeded to remove the already removed contact");
+       else if (!g_error_matches (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND))
+               g_error ("Wrong error in remove 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
@@ -106,10 +116,19 @@ main (gint argc,
 #endif
        g_test_init (&argc, &argv, NULL);
 
+       setlocale (LC_ALL, "en_US.UTF-8");
+
        g_test_add ("/EBookClient/RemoveContact/Sync", ETestServerFixture, &book_closure,
                    e_test_server_utils_setup, test_remove_contact_sync, e_test_server_utils_teardown);
        g_test_add ("/EBookClient/RemoveContact/Async", ETestServerFixture, &book_closure,
                    e_test_server_utils_setup, test_remove_contact_async, e_test_server_utils_teardown);
 
+       /* We run the direct access variants here because we're interested in testing the error
+        * code from e_book_client_get_contact(removed_contact_uid)  */
+       g_test_add ("/EBookClient/DirectAccess/RemoveContact/Sync", ETestServerFixture, &book_closure,
+                   e_test_server_utils_setup, test_remove_contact_sync, e_test_server_utils_teardown);
+       g_test_add ("/EBookClient/DirectAccess/RemoveContact/Async", ETestServerFixture, &book_closure,
+                   e_test_server_utils_setup, test_remove_contact_async, e_test_server_utils_teardown);
+
        return e_test_server_utils_run ();
 }


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