[couchdb-glib] Add test for desktopcouch contacts
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [couchdb-glib] Add test for desktopcouch contacts
- Date: Thu, 31 Mar 2011 16:30:23 +0000 (UTC)
commit 079164b6f39112dae54bde80de11655b6cd4a3d0
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Thu Mar 31 18:30:08 2011 +0200
Add test for desktopcouch contacts
couchdb-glib/couchdb-document.c | 8 ++++----
tests/test-desktopcouch-glib.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/couchdb-glib/couchdb-document.c b/couchdb-glib/couchdb-document.c
index 1a0a57e..a81cd54 100644
--- a/couchdb-glib/couchdb-document.c
+++ b/couchdb-glib/couchdb-document.c
@@ -738,8 +738,8 @@ couchdb_document_is_contact (CouchdbDocument *document)
{
g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), FALSE);
- return !g_ascii_strcasecmp (couchdb_document_get_record_type (document),
- COUCHDB_RECORD_TYPE_CONTACT);
+ return !g_strcmp0 (couchdb_document_get_record_type (document),
+ COUCHDB_RECORD_TYPE_CONTACT);
}
/**
@@ -756,6 +756,6 @@ couchdb_document_is_task (CouchdbDocument *document)
{
g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), FALSE);
- return !g_ascii_strcasecmp (couchdb_document_get_record_type (document),
- COUCHDB_RECORD_TYPE_TASK);
+ return !g_strcmp0 (couchdb_document_get_record_type (document),
+ COUCHDB_RECORD_TYPE_TASK);
}
diff --git a/tests/test-desktopcouch-glib.c b/tests/test-desktopcouch-glib.c
index a99c328..ad06289 100644
--- a/tests/test-desktopcouch-glib.c
+++ b/tests/test-desktopcouch-glib.c
@@ -52,6 +52,36 @@ test_list_databases (void)
couchdb_session_free_database_list (dblist);
}
+static void
+test_contacts (void)
+{
+ GError *error;
+ CouchdbDatabase *db;
+
+ db = couchdb_session_get_database (dc, "contacts", &error);
+ if (COUCHDB_IS_DATABASE (db)) {
+ GSList *doc_list;
+
+ error = NULL;
+ doc_list = couchdb_database_get_all_documents (db, &error);
+ while (doc_list) {
+ CouchdbDocument *document = doc_list->data;
+
+ if (couchdb_document_is_contact (document)) {
+ g_assert (g_str_equal (couchdb_document_get_record_type (document), COUCHDB_RECORD_TYPE_CONTACT));
+ }
+
+ doc_list = g_slist_remove (doc_list, document);
+ }
+
+ g_object_unref (db);
+ } else if (error) {
+ g_warning ("Couldn't get 'contacts' database: %s", error->message);
+ g_error_free (error);
+ } else
+ g_assert (FALSE);
+}
+
int
main (int argc, char *argv[])
{
@@ -61,6 +91,7 @@ main (int argc, char *argv[])
g_test_add_func ("/testdesktopcouchglib/Connect", test_connect_desktopcouch);
g_test_add_func ("/testdesktopcouchglib/ListDatabases", test_list_databases);
+ g_test_add_func ("/testdesktopcouchglib/ListContacts", test_contacts);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]