[couchdb-glib] Added simple test for desktopcouch object



commit c51660d2bf04020bafb66578e6d0f01cb1c3770a
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Fri Jan 8 16:47:33 2010 +0100

    Added simple test for desktopcouch object

 .gitignore                       |    1 +
 desktopcouch-glib/desktopcouch.c |    3 +-
 tests/Makefile.am                |   19 +++++++++++++--
 tests/test-desktopcouch-glib.c   |   44 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 62 insertions(+), 5 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 330190b..d75c6aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,5 +36,6 @@ m4/ltsugar.m4
 m4/ltversion.m4
 m4/lt~obsolete.m4
 tests/test-couchdb-glib
+tests/test-desktopcouch-glib
 tests/test-oauth
 tests/test-list-databases
diff --git a/desktopcouch-glib/desktopcouch.c b/desktopcouch-glib/desktopcouch.c
index c9efc90..18b3969 100644
--- a/desktopcouch-glib/desktopcouch.c
+++ b/desktopcouch-glib/desktopcouch.c
@@ -115,6 +115,7 @@ desktopcouch_new (void)
 			gnome_keyring_found_list_free (items_found);
 
 			/* Enable OAuth on this connection */
+			dc = DESKTOPCOUCH (g_object_new (DESKTOPCOUCH_TYPE, "uri", uri, NULL));
 			couchdb_enable_oauth (COUCHDB (dc),
 					      oauth_c_key,
 					      oauth_c_secret,
@@ -126,8 +127,6 @@ desktopcouch_new (void)
 			g_free (oauth_t_key);
 			g_free (oauth_t_secret);
 
-			dc = DESKTOPCOUCH (g_object_new (DESKTOPCOUCH_TYPE, "uri", uri, NULL));
-
 			g_free (uri);
 
 			return dc;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fb9f7b0..dc0f20c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,9 +1,12 @@
-INCLUDES =			\
-	$(COUCHDB_GLIB_CFLAGS)	\
-	-I$(top_srcdir)/couchdb-glib
+INCLUDES =				\
+	$(COUCHDB_GLIB_CFLAGS)		\
+	$(DESKTOPCOUCH_GLIB_CFLAGS)	\
+	-I$(top_srcdir)/couchdb-glib	\
+	-I$(top_srcdir)/desktopcouch-glib
 
 noinst_PROGRAMS = 		\
 	test-couchdb-glib	\
+	test-desktopcouch-glib	\
 	test-list-databases	\
 	test-oauth
 
@@ -21,6 +24,15 @@ test_couchdb_glib_LDADD = 	\
 	-luuid			\
 	$(top_builddir)/couchdb-glib/libcouchdb-glib-1.0.la
 
+test_desktopcouch_glib_SOURCES = test-desktopcouch-glib.c
+test_desktopcouch_glib_LDADD =       				\
+	$(COUCHDB_GLIB_LIBS)    				\
+	$(DESKTOPCOUCH_GLIB_LIBS)				\
+	$(OAUTH_LIBS)           				\
+	-luuid                  				\
+	$(top_builddir)/couchdb-glib/libcouchdb-glib-1.0.la	\
+	$(top_builddir)/desktopcouch-glib/libdesktopcouch-glib-1.0.la
+
 test_oauth_SOURCES = test-oauth.c
 test_oauth_LDADD = 	\
 	$(COUCHDB_GLIB_LIBS)	\
@@ -34,3 +46,4 @@ check_PROGRAMS = test-couchdb-glib
 
 test: $(check_PROGRAMS)
 	$(top_srcdir)/tests/test-couchdb-glib
+	$(top_srcdir)/tests/test-desktopcouch-glib
diff --git a/tests/test-desktopcouch-glib.c b/tests/test-desktopcouch-glib.c
new file mode 100644
index 0000000..672f874
--- /dev/null
+++ b/tests/test-desktopcouch-glib.c
@@ -0,0 +1,44 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Canonical Services Ltd (www.canonical.com)
+ *
+ * Authors: Rodrigo Moya <rodrigo moya canonical com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <desktopcouch-glib.h>
+
+static Desktopcouch *dc = NULL;
+
+static void
+test_connect_desktopcouch (void)
+{
+	dc = desktopcouch_new ();
+
+	g_assert (DESKTOPCOUCH_IS (dc));
+}
+
+int
+main (int argc, char *argv[])
+{
+	g_type_init ();
+	g_thread_init (NULL);
+	g_test_init (&argc, &argv, NULL);
+
+	g_test_add_func ("/testdesktopcouchglib/Connect", test_connect_desktopcouch);
+
+	return g_test_run ();
+}



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