[couchdb-glib/wip/query-response] write tests for couchdb_session_has_database



commit 68edcd07d730d4c3bf604958a727a963cc67752d
Author: Krzysztof Klimonda <kklimonda syntaxhighlighted com>
Date:   Wed Jan 19 14:30:51 2011 +0100

    write tests for couchdb_session_has_database

 tests/test-couchdb-session.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/tests/test-couchdb-session.c b/tests/test-couchdb-session.c
index a4d5b83..41a2b56 100644
--- a/tests/test-couchdb-session.c
+++ b/tests/test-couchdb-session.c
@@ -209,6 +209,24 @@ test_session_execute_simple_queries (gconstpointer user_data)
 	g_object_unref (response);
 }
 
+static void
+test_session_has_database (CouchdbFixture *fixture, gconstpointer user_data)
+{
+	gboolean result;
+
+	result = couchdb_session_has_database(fixture->session, "simple_database");
+	g_assert (result == TRUE);
+
+	result = couchdb_session_has_database(fixture->session, "database/with/slashes");
+	g_assert (result == TRUE);
+
+	result = couchdb_session_has_database(fixture->session, "database/with0/_$()+-");
+	g_assert (result == TRUE);
+
+	result = couchdb_session_has_database(fixture->session, "no_such_database");
+	g_assert (result == FALSE);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -220,7 +238,7 @@ main (int argc, char *argv[])
 	g_thread_init (NULL);
 	g_test_init (&argc, &argv, NULL);
 
-	uri = "http://localhost:5985";;
+	uri = "http://localhost:5984";;
 
 	session = couchdb_session_new (uri);
 	databases = couchdb_session_list_databases (session, NULL);
@@ -240,6 +258,10 @@ main (int argc, char *argv[])
 		    uri, couchdb_fixture_setup,
 		    test_session_list_databases,
 		    couchdb_fixture_teardown);
+	g_test_add ("/CouchDB/Session/HasDatabase", CouchdbFixture,
+		    uri, couchdb_fixture_setup,
+		    test_session_has_database,
+		    couchdb_fixture_teardown);
 
 	return g_test_run ();
 }



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