[couchdb-glib] Add thread test for desktopcouch



commit db339c1212a750de7bbe009d71459d017eb76b3e
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Fri Apr 1 17:28:18 2011 +0200

    Add thread test for desktopcouch

 couchdb-glib/couchdb-session.c |    6 +++---
 tests/test-desktopcouch-glib.c |   26 ++++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/couchdb-glib/couchdb-session.c b/couchdb-glib/couchdb-session.c
index c995751..1e8d0a5 100644
--- a/couchdb-glib/couchdb-session.c
+++ b/couchdb-glib/couchdb-session.c
@@ -557,9 +557,9 @@ couchdb_session_is_authentication_enabled (CouchdbSession *session)
 }
 
 static gboolean
-_session_authenticate(SoupSession *http_session, SoupMessage *msg,
-		      SoupAuth *auth, gboolean retrying,
-		      gpointer callback_data)
+_session_authenticate (SoupSession *http_session, SoupMessage *msg,
+		       SoupAuth *auth, gboolean retrying,
+		       gpointer callback_data)
 {
 	CouchdbSession *session;
 
diff --git a/tests/test-desktopcouch-glib.c b/tests/test-desktopcouch-glib.c
index 6c45d1e..11da8f6 100644
--- a/tests/test-desktopcouch-glib.c
+++ b/tests/test-desktopcouch-glib.c
@@ -31,6 +31,27 @@ test_connect_desktopcouch (void)
 	g_assert (DESKTOPCOUCH_IS_SESSION (dc));
 }
 
+gpointer
+connect_thread (gpointer data)
+{
+	dc = desktopcouch_session_new ();
+	g_assert (DESKTOPCOUCH_IS_SESSION (dc));
+
+	return dc;
+}
+
+static void
+test_connect_thread (void)
+{
+	GThread *thread;
+
+	if (!g_thread_get_initialized ())
+		g_thread_init (NULL);
+
+	thread = g_thread_create ((GThreadFunc) connect_thread, NULL, TRUE, NULL);
+	g_assert (g_thread_join (thread));
+}
+
 static void
 test_list_databases (void)
 {
@@ -58,7 +79,7 @@ test_contacts (void)
 	GError *error;
 	CouchdbDatabase *db;
 
-	db = couchdb_session_get_database (dc, "contacts", &error);
+	db = couchdb_session_get_database (COUCHDB_SESSION (dc), "contacts", &error);
 	if (COUCHDB_IS_DATABASE (db)) {
 		GSList *doc_list;
 
@@ -68,7 +89,7 @@ test_contacts (void)
 			CouchdbDocument *document = doc_list->data;
 
 			if (couchdb_document_is_contact (document)) {
-				g_assert (g_strcmp0 (couchdb_document_get_record_type (document), COUCHDB_RECORD_TYPE_CONTACT));
+				g_assert (g_strcmp0 (couchdb_document_get_record_type (document), COUCHDB_RECORD_TYPE_CONTACT) == 0);
 			}
 
 			doc_list = g_slist_remove (doc_list, document);
@@ -90,6 +111,7 @@ main (int argc, char *argv[])
 	g_test_init (&argc, &argv, NULL);
 
 	g_test_add_func ("/testdesktopcouchglib/Connect", test_connect_desktopcouch);
+	g_test_add_func ("/testdesktopcouchglib/ConnectOnThread", test_connect_thread);
 	g_test_add_func ("/testdesktopcouchglib/ListDatabases", test_list_databases);
 	g_test_add_func ("/testdesktopcouchglib/ListContacts", test_contacts);
 



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