[tracker/direct-access: 28/38] tests/functional-tests: Add update tests
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/direct-access: 28/38] tests/functional-tests: Add update tests
- Date: Mon, 16 Aug 2010 12:18:03 +0000 (UTC)
commit caa2fe7703092238482b66b3224c78179528bb54
Author: Philip Van Hoof <philip codeminded be>
Date: Wed Jul 21 17:42:18 2010 +0200
tests/functional-tests: Add update tests
tests/functional-tests/.gitignore | 6 ++-
tests/functional-tests/Makefile.am | 27 +++++++++++++++-
tests/functional-tests/direct-update-test.vala | 41 ++++++++++++++++++++++++
3 files changed, 71 insertions(+), 3 deletions(-)
---
diff --git a/tests/functional-tests/.gitignore b/tests/functional-tests/.gitignore
index 9cccbdc..c8fef55 100644
--- a/tests/functional-tests/.gitignore
+++ b/tests/functional-tests/.gitignore
@@ -2,10 +2,12 @@ shared-query-test.c
shared-update-test.c
bus-query-test
bus-query-test.c
+direct-query-test
+direct-query-test.c
bus-update-test
bus-update-test.c
-direct-test
-direct-test.c
+direct-update-test
+direct-update-test.c
ttl
force-sqlite-misused-batch.sh
force-sqlite-misused.sh
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index ab0aeb8..8e0cbfe 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -54,7 +54,7 @@ bashscripts_SCRIPTS = \
@sed -e "s|@topsrcdir[ ]|${top_srcdir}|" \
-e "s|@libexecdir[ ]|${libexecdir}|" $< > $@
-noinst_PROGRAMS = busy-handling-test direct-query-test bus-query-test bus-update-test
+noinst_PROGRAMS = busy-handling-test direct-query-test bus-query-test direct-update-test bus-update-test
busy_handling_test_VALASOURCES = busy-handling-test.vala
@@ -111,12 +111,24 @@ direct_query_test_SOURCES = \
direct_query_test.vala.stamp \
$(direct_query_test_VALASOURCES:.vala=.c)
+direct_update_test_VALASOURCES = direct-update-test.vala
+
+direct_update_test_SOURCES = \
+ direct_update_test.vala.stamp \
+ $(direct_update_test_VALASOURCES:.vala=.c)
+
bus_query_test_VALASOURCES = bus-query-test.vala
bus_query_test_SOURCES = \
bus_query_test.vala.stamp \
$(bus_query_test_VALASOURCES:.vala=.c)
+bus_update_test_VALASOURCES = bus-update-test.vala
+
+bus_update_test_SOURCES = \
+ bus_update_test.vala.stamp \
+ $(bus_update_test_VALASOURCES:.vala=.c)
+
direct_vapi_sources = \
$(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi \
$(top_srcdir)/src/libtracker-direct/tracker-direct-$(TRACKER_API_VERSION).vapi
@@ -131,6 +143,12 @@ direct_query_test_LDADD = \
$(GIO_LIBS) \
$(GLIB2_LIBS)
+direct-update-test.vala.stamp: $(direct_update_test_VALASOURCES) $(direct_vapi_sources)
+ $(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 $^
+ $(AM_V_GEN)touch $@
+
+direct_update_test_LDADD = $(direct_query_test_LDADD)
+
bus_vapi_sources = \
$(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi \
$(top_srcdir)/src/libtracker-bus/tracker-bus-$(TRACKER_API_VERSION).vapi
@@ -139,6 +157,10 @@ bus-query-test.vala.stamp: $(bus_query_test_VALASOURCES) $(bus_vapi_sources)
$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 --pkg dbus-glib-1 $^
$(AM_V_GEN)touch $@
+bus-update-test.vala.stamp: $(bus_update_test_VALASOURCES) $(bus_vapi_sources)
+ $(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 --pkg dbus-glib-1 $^
+ $(AM_V_GEN)touch $@
+
bus_query_test_LDADD = \
$(top_builddir)/src/libtracker-bus/libtracker-bus.la \
$(top_builddir)/src/libtracker-sparql/libtracker-sparql-$(TRACKER_API_VERSION).la \
@@ -151,8 +173,11 @@ BUILT_SOURCES = \
busy-handling-test.vala.stamp \
direct-query-test.vala.stamp \
bus-query-test.vala.stamp \
+ direct-update-test.vala.stamp \
bus-update-test.vala.stamp
+bus_update_test_LDADD = $(bus_query_test_LDADD)
+
EXTRA_DIST = \
$(config_SCRIPTS) \
$(bashscripts_SCRIPTS) \
diff --git a/tests/functional-tests/direct-update-test.vala b/tests/functional-tests/direct-update-test.vala
new file mode 100644
index 0000000..d676c1c
--- /dev/null
+++ b/tests/functional-tests/direct-update-test.vala
@@ -0,0 +1,41 @@
+using Tracker;
+using Tracker.Sparql;
+
+private int iter_cursor (Cursor cursor)
+{
+ try {
+ while (cursor.next()) {
+ int i;
+
+ for (i = 0; i < cursor.n_columns; i++) {
+ print ("%s%s", i != 0 ? ",":"", cursor.get_string (i));
+ }
+
+ print ("\n");
+ }
+ } catch (GLib.Error e) {
+ warning ("Couldn't iterate query results: %s", e.message);
+ return -1;
+ }
+
+ return (0);
+}
+
+int
+main( string[] args )
+{
+ Sparql.Connection con = new Tracker.Direct.Connection ();
+ Cursor cursor;
+ int a;
+
+ try {
+ con.update ("INSERT { <test01> a nie:InformationElement ; nie:title 'test01' }");
+ cursor = con.query ("SELECT ?title WHERE { <test01> nie:title ?title }");
+ a = iter_cursor (cursor);
+ } catch (GLib.Error e) {
+ warning ("Couldn't perform query: %s", e.message);
+ return -1;
+ }
+
+ return a;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]