[couchdb-glib: 16/21] Allow test-couchdb-glib and test-list-databases to take the URL



commit 6b14d18c6f8bbbbcc23e703b402e0ad56679dcc6
Author: Mikkel Kamstrup Erlandsen <mikkel kamstrup gmail com>
Date:   Tue Oct 6 11:21:06 2009 +0200

    Allow test-couchdb-glib and test-list-databases to take the URL
    to a database server as an optional first argument. This makes
    testing a bit easier.
    
    Better error messages from tests on connection errors

 tests/test-couchdb-glib.c   |    9 +++++++--
 tests/test-list-databases.c |   11 +++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/tests/test-couchdb-glib.c b/tests/test-couchdb-glib.c
index 881dd86..e0f8143 100644
--- a/tests/test-couchdb-glib.c
+++ b/tests/test-couchdb-glib.c
@@ -117,7 +117,10 @@ test_change_databases (void)
 
 	/* Create database */
 	couchdb_create_database (couchdb, dbname, &error);
-	g_assert (error == NULL);
+	if (error) {
+		g_critical ("Error creating database '%s': %s", dbname, error->message);
+		g_error_free (error);
+	}
 
 	couchdb_listen_for_changes (couchdb, dbname);
 
@@ -189,7 +192,9 @@ main (int argc, char *argv[])
 	g_test_init (&argc, &argv, NULL);
 
 	/* Initialize data needed for all tests */
-	couchdb = couchdb_new (NULL);
+	couchdb =  argc > 1 ? couchdb_new (argv[1]) : couchdb_new (NULL);
+	g_printf ("Connecting to CouchDB at %s\n", couchdb_get_hostname (couchdb));
+	
 	if (!couchdb) {
 		g_print ("Could not create CouchDB object\n");
 		return -1;
diff --git a/tests/test-list-databases.c b/tests/test-list-databases.c
index 4dd5efb..a8eb502 100644
--- a/tests/test-list-databases.c
+++ b/tests/test-list-databases.c
@@ -32,14 +32,21 @@ main (int argc, char *argv[])
 	g_type_init ();
 	g_thread_init (NULL);
 
-	/* initialize CouchDB */
-	couchdb = couchdb_new (NULL);
+	/* Initialize CouchDB */
+	couchdb =  argc > 1 ? couchdb_new (argv[1]) : couchdb_new (NULL);
+	g_printf ("Connecting to CouchDB at %s\n", couchdb_get_hostname (couchdb));
+	
 	if (!couchdb) {
 		g_print ("Could not create CouchDB object\n");
 		return -1;
 	}
 
 	dblist = couchdb_list_databases (couchdb, &error);
+	if (error != NULL) {
+		g_critical ("Error listing databases: %s", error->message);
+		g_error_free (error);
+	}
+	
 	for (sl = dblist; sl != NULL; sl = sl->next) {
 		CouchDBDatabaseInfo *dbinfo;
 		GSList *doclist;



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