[tracker/wip/carlosg/tracker-3.0-api-breaks: 35/95] tests: Make libtracker-sparql tests use local connection



commit d0295479202ea0f9b36896bfa277da69a77dbe94
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Dec 23 01:44:40 2019 +0100

    tests: Make libtracker-sparql tests use local connection
    
    Perhaps it should use local connection + endpoint + dbus connection
    to be more similar to what it used to do. But this should suffice to
    verify the tested behavior.

 tests/libtracker-sparql/tracker-sparql-test.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/tests/libtracker-sparql/tracker-sparql-test.c b/tests/libtracker-sparql/tracker-sparql-test.c
index 9fa2fcc2b..a730dea97 100644
--- a/tests/libtracker-sparql/tracker-sparql-test.c
+++ b/tests/libtracker-sparql/tracker-sparql-test.c
@@ -56,6 +56,27 @@ static const gchar *queries[N_QUERIES] = {
        "SELECT ?p WHERE { ?p tracker:fulltextIndexed true }",
 };
 
+TrackerSparqlConnection *
+create_local_connection (GError **error)
+{
+       TrackerSparqlConnection *conn;
+       GFile *store, *ontology;
+       gchar *path;
+
+       path = g_build_filename (g_get_tmp_dir (), "libtracker-sparql-test-XXXXXX", NULL);
+       g_mkdtemp_full (path, 0700);
+       store = g_file_new_for_path (path);
+       g_free (path);
+
+       ontology = g_file_new_for_path (TEST_ONTOLOGIES_DIR);
+
+       conn = tracker_sparql_connection_new (0, store, ontology, NULL, error);
+       g_object_unref (store);
+       g_object_unref (ontology);
+
+       return conn;
+}
+
 static void
 test_tracker_sparql_escape_string (void)
 {
@@ -191,7 +212,7 @@ test_tracker_sparql_cursor_next_async (void)
         * 3. Handle multiple async queries + async cursor_next() calls.
         */
 
-       connection = tracker_sparql_connection_get (NULL, &error);
+       connection = create_local_connection (&error);
        g_assert_no_error (error);
        g_assert (connection != NULL);
 
@@ -210,7 +231,7 @@ test_tracker_sparql_connection_interleaved (void)
 
        const gchar* query = "select ?u {?u a rdfs:Resource .}";
 
-       connection = tracker_sparql_connection_get (NULL, &error);
+       connection = create_local_connection (&error);
        g_assert_no_error (error);
 
        cursor1 = tracker_sparql_connection_query (connection, query, 0, &error);


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