[couchdb-glib] Make tests start a standalone CouchDB instance



commit 2845f1854d1ea99907eb62111ebc27e2e9b12bed
Author: Adi Roiban <adiroiban ubuntu com>
Date:   Fri Apr 9 16:55:31 2010 +0200

    Make tests start a standalone CouchDB instance

 tests/Makefile.am         |   33 +++++++++++++++++++++++++++++++--
 tests/test-couchdb-glib.c |    4 ++++
 2 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dc0f20c..dd79d03 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,7 @@
+NULL = 
+SUBDIRS = \
+        $(NULL)
+
 INCLUDES =				\
 	$(COUCHDB_GLIB_CFLAGS)		\
 	$(DESKTOPCOUCH_GLIB_CFLAGS)	\
@@ -44,6 +48,31 @@ EXTRA_DIST = createCouchContacts.py test-oauth.py
 
 check_PROGRAMS = test-couchdb-glib
 
+
+COUCHDB_VAR = $(top_srcdir)/tests/var
+COUCHDB_PID = $(top_srcdir)/tests/config/couchdb.pid
+COUCHDB_STDOUT = $(top_srcdir)/tests/var/couchdb.stdout
+COUCHDB_STDERR = $(top_srcdir)/tests/var/couchdb.stderr
+COUCHDB_CONFIG_NOAUTH = $(top_srcdir)/tests/config/couchdb-noauth.ini
+COUCHDB_CONFIG_AUTH = $(top_srcdir)/tests/config/couchdb-auth.ini
+
+
+stop-couchdb:
+	@/usr/bin/couchdb -p $(COUCHDB_PID) -d
+	@/bin/rm -f $(COUCHDB_PID)
+
 test: $(check_PROGRAMS)
-	$(top_srcdir)/tests/test-couchdb-glib
-	$(top_srcdir)/tests/test-desktopcouch-glib
+	@echo "Setting up the couchdb server..."
+	@/bin/rm -rf $(COUCHDB_VAR)
+	@/bin/mkdir -p $(COUCHDB_VAR)
+	@/usr/bin/couchdb -p $(COUCHDB_PID) -d > /dev/null
+	@/usr/bin/couchdb -n -a /etc/couchdb/default.ini \
+	    -o $(COUCHDB_STDOUT) -e $(COUCHDB_STDERR) \
+	    -a $(COUCHDB_CONFIG_AUTH) -p $(COUCHDB_PID) -b > /dev/null
+	@/bin/sleep 1
+	@$(top_srcdir)/tests/test-couchdb-glib "http://test:test 127 0 0 1:5984"
+	@echo "Tearing down up the couchdb server..."
+	@/usr/bin/couchdb -p $(COUCHDB_PID) -d > /dev/null
+	@/bin/rm -f $(COUCHDB_PID)
+	@/bin/rm -rf $(COUCHDB_VAR)
+	@$(top_srcdir)/tests/test-desktopcouch-glib
diff --git a/tests/test-couchdb-glib.c b/tests/test-couchdb-glib.c
index cc283ef..465839f 100644
--- a/tests/test-couchdb-glib.c
+++ b/tests/test-couchdb-glib.c
@@ -115,6 +115,10 @@ test_change_databases (void)
 	dbname = generate_uuid ();
 	g_assert (dbname != NULL);
 
+	/* Database name can not start with a digit
+	 * we will overwrite the first character with 'a' */
+	 dbname[0] = 'a';
+
 	/* Create database */
 	couchdb_session_create_database (couchdb, dbname, &error);
 	if (error) {



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