GNOME Bugzilla – Bug 694188
sqlite backend: non-standard "not found" error
Last modified: 2013-09-14 16:56:17 UTC
SyncEvolution has a test which checks the result of removing a contact which doesn't exist. The expectation is that e_book_client_remove_contact_by_uid_sync() returns E_BOOK_CLIENT_ERROR/E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND. This started to fail with the introduction of the sqlite backend.
Created attachment 236789 [details] [review] return known error code
Currently EBookBackendSQLiteDB has it's own error codes, and returns an explicit error E_BOOK_SDB_ERROR_CONTACT_NOT_FOUND. The EBookBackendFile makes sure to translate this to the correct EDataBookStatus And the test case test-client-remove-contact.c ensures that E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND is reported after a contact is removed.
(In reply to comment #2) > Currently EBookBackendSQLiteDB has it's own error codes, and > returns an explicit error E_BOOK_SDB_ERROR_CONTACT_NOT_FOUND. > > The EBookBackendFile makes sure to translate this to the correct > EDataBookStatus That didn't work for me. I don't know how the mapping works, so I can't come up with a different patch. > And the test case test-client-remove-contact.c ensures that > E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND is reported after > a contact is removed. There's a misunderstanding. The test checks that get_contact returns E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND. That works. What also needs to work is that remove_contact_by_uid, too, returns E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND when the uid is not found. That doesn't work. Instead the client gets the incomprehensible, backend internal error code.
Change the test as follows and it'll fail: diff --git a/tests/libebook/client/test-client-remove-contact.c b/tests/libebook/client/test-client-remove-contact.c index bb314aa..bdc88dd 100644 --- a/tests/libebook/client/test-client-remove-contact.c +++ b/tests/libebook/client/test-client-remove-contact.c @@ -21,6 +21,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 removed contact again"); + 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 ** (/work/gnome/checkout/evolution-data-server/tests/libebook/client/.libs/lt-test-client-remove-contact:9386): ERROR **: Wrong error in remove contact sync on removed contact: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._e_2dbook_2dbackend_2dsqlitedb_2derror_2dquark.Code1: Cannot remove contacts: Contact 'pas-id-512639F200000000' not found (domain: e-book-backend-sqlitedb-error-quark, code: 1)
Fixed in master with these commits: commit 4cbd466c71012968d998b06c1a13c959340d18c2 Author: Tristan Van Berkom <tristanvb@openismus.com> Date: Fri Feb 22 18:33:07 2013 +0900 EBookBackendFile: Report the correct error from remove_contacts() If the EBookBackenSqliteDB reports CONTACT_NOT_FOUND, then use E_DATA_BOOK_STATUS_CONTACT_NOT_FOUND, this causes test-client-remove-contact to pass again. See bug: https://bugzilla.gnome.org/show_bug.cgi?id=694188 commit 97a725e8546c2f5e0566312bc81d1c518bcd9eec 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 See bug: https://bugzilla.gnome.org/show_bug.cgi?id=694188