[tracker/wip/carlosg/bindings-in-service: 6/6] tests: Add test for TrackerSparqlStatement bindings in SERVICE{}
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/bindings-in-service: 6/6] tests: Add test for TrackerSparqlStatement bindings in SERVICE{}
- Date: Mon, 4 May 2020 23:10:29 +0000 (UTC)
commit 6c2a4476c12a415fb712cd98b7d284c2d1419912
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue May 5 00:41:04 2020 +0200
tests: Add test for TrackerSparqlStatement bindings in SERVICE{}
This was broken, but no more. Make the direct and bus connections
use a separate store to avoid sqlite deadlocks, and test SERVICE{}
queries in the direct connection to make sure it doesn't regress.
tests/libtracker-sparql/statement/service.out | 1 +
tests/libtracker-sparql/statement/service.rq | 5 +++++
tests/libtracker-sparql/tracker-statement-test.c | 28 +++++++++++++++++++-----
3 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/tests/libtracker-sparql/statement/service.out b/tests/libtracker-sparql/statement/service.out
new file mode 100644
index 000000000..056950364
--- /dev/null
+++ b/tests/libtracker-sparql/statement/service.out
@@ -0,0 +1 @@
+"http://tracker.api.gnome.org/ontology/v3/nmm#MusicAlbum"
diff --git a/tests/libtracker-sparql/statement/service.rq b/tests/libtracker-sparql/statement/service.rq
new file mode 100644
index 000000000..f5569ddee
--- /dev/null
+++ b/tests/libtracker-sparql/statement/service.rq
@@ -0,0 +1,5 @@
+SELECT ?u {
+ SERVICE <dbus:%s> {
+ ?u rdfs:label ~arg1 .
+ }
+}
diff --git a/tests/libtracker-sparql/tracker-statement-test.c
b/tests/libtracker-sparql/tracker-statement-test.c
index 48c82a637..38523fb51 100644
--- a/tests/libtracker-sparql/tracker-statement-test.c
+++ b/tests/libtracker-sparql/tracker-statement-test.c
@@ -32,6 +32,7 @@ typedef struct {
const gchar *arg1;
const gchar *arg2;
const gchar *arg3;
+ gboolean service;
TrackerSparqlConnection *conn;
} TestInfo;
@@ -43,6 +44,7 @@ TestInfo tests[] = {
{ "subject", "statement/subject.rq", "statement/subject.out",
"http://tracker.api.gnome.org/ontology/v3/nmm#MusicAlbum" },
{ "subject-2", "statement/subject.rq", "statement/subject-2.out", "urn:nonexistent" },
{ "filter", "statement/filter.rq", "statement/filter.out",
"http://tracker.api.gnome.org/ontology/v3/nmm#MusicAlbum", "Music album" },
+ { "service", "statement/service.rq", "statement/service.out", "Music album", NULL, NULL, TRUE },
};
typedef struct {
@@ -51,6 +53,7 @@ typedef struct {
} StartupData;
static gboolean started = FALSE;
+static const gchar *bus_name = NULL;
static void
check_result (TrackerSparqlCursor *cursor,
@@ -160,6 +163,14 @@ query_statement (TestInfo *test_info,
g_assert_no_error (error);
g_free (path);
+ if (test_info->service) {
+ gchar *service_query;
+
+ service_query = g_strdup_printf (query, bus_name);
+ g_free (query);
+ query = service_query;
+ }
+
stmt = tracker_sparql_connection_query_statement (test_info->conn, query,
NULL, &error);
g_free (query);
@@ -203,7 +214,7 @@ create_local_connection (GError **error)
static gpointer
thread_func (gpointer user_data)
{
- StartupData *data = user_data;;
+ StartupData *data = user_data;
TrackerEndpointDBus *endpoint;
GMainContext *context;
GMainLoop *main_loop;
@@ -242,22 +253,27 @@ create_connections (TrackerSparqlConnection **dbus,
while (!started)
g_usleep (100);
- *dbus = tracker_sparql_connection_bus_new (g_dbus_connection_get_unique_name (data.dbus_conn),
+ bus_name = g_dbus_connection_get_unique_name (data.dbus_conn);
+ *dbus = tracker_sparql_connection_bus_new (bus_name,
NULL, data.dbus_conn, error);
- *direct = data.direct;
+ *direct = create_local_connection (error);
return TRUE;
}
static void
add_tests (TrackerSparqlConnection *conn,
- const gchar *name)
+ const gchar *name,
+ gboolean run_service_tests)
{
gint i;
for (i = 0; i < G_N_ELEMENTS (tests); i++) {
gchar *testpath;
+ if (tests[i].service && !run_service_tests)
+ continue;
+
tests[i].conn = conn;
testpath = g_strconcat ("/libtracker-sparql/statement/", name, "/", tests[i].test_name, NULL);
g_test_add (testpath, TestInfo, &tests[i], setup, query_statement, NULL);
@@ -276,8 +292,8 @@ main (gint argc, gchar **argv)
g_assert_true (create_connections (&dbus, &direct, &error));
g_assert_no_error (error);
- add_tests (direct, "direct");
- add_tests (dbus, "dbus");
+ add_tests (direct, "direct", TRUE);
+ add_tests (dbus, "dbus", FALSE);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]