diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2021-04-04 12:52:23 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2021-04-15 12:26:42 +0200 |
commit | b15aed22cacf0039b73e4bd205531ae29d7524b7 (patch) | |
tree | 6f9fa3b9eba5ee2c7dc16f1dab0a303e4a8d30fa | |
parent | 9f124721aae7be93df0d18c8eda2f6772ee7efb6 (diff) | |
download | tracker-wip/carlosg/local-connection-mapping.tar.gz |
tests: Test locally mapped connections in the services testswip/carlosg/local-connection-mapping
Also relate the 2 connections via tracker_sparql_connection_map_connection
so we can test the "local:xyz" special URIs.
-rw-r--r-- | tests/libtracker-data/tracker-service-test.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/tests/libtracker-data/tracker-service-test.c b/tests/libtracker-data/tracker-service-test.c index 7d587c05f..3f89e9ed5 100644 --- a/tests/libtracker-data/tracker-service-test.c +++ b/tests/libtracker-data/tracker-service-test.c @@ -32,6 +32,7 @@ typedef struct _TestInfo TestInfo; struct _TestInfo { const gchar *test_name; gboolean expect_query_error; + gboolean local_connection; }; const TestInfo tests[] = { @@ -204,6 +205,10 @@ test_sparql_query (TestInfo *test_info, g_usleep (100); } + tracker_sparql_connection_map_connection (local, + "other-connection", + remote); + query_filename = g_strconcat (test_prefix, ".rq", NULL); g_file_get_contents (query_filename, &query, NULL, &error); g_assert_no_error (error); @@ -212,8 +217,12 @@ test_sparql_query (TestInfo *test_info, results_filename = g_strconcat (test_prefix, ".out", NULL); g_free (test_prefix); - uri = g_strdup_printf ("dbus:%s", - g_dbus_connection_get_unique_name (dbus_conn)); + if (test_info->local_connection) { + uri = g_strdup_printf ("local:other-connection"); + } else { + uri = g_strdup_printf ("dbus:%s", + g_dbus_connection_get_unique_name (dbus_conn)); + } /* perform actual query */ service_query = g_strdup_printf (query, uri); @@ -247,6 +256,16 @@ setup (TestInfo *info, } static void +setup_local (TestInfo *info, + gconstpointer context) +{ + const TestInfo *test = context; + + *info = *test; + info->local_connection = TRUE; +} + +static void teardown (TestInfo *info, gconstpointer context) { @@ -266,15 +285,24 @@ main (int argc, char **argv) dbus_conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); g_assert_no_error (error); - /* add test cases */ + /* add DBus test cases */ for (i = 0; i < G_N_ELEMENTS (tests); i++) { gchar *testpath; - testpath = g_strconcat ("/libtracker-data/", tests[i].test_name, NULL); + testpath = g_strconcat ("/libtracker-data/dbus/", tests[i].test_name, NULL); g_test_add (testpath, TestInfo, &tests[i], setup, test_sparql_query, teardown); g_free (testpath); } + /* add local test cases */ + for (i = 0; i < G_N_ELEMENTS (tests); i++) { + gchar *testpath; + + testpath = g_strconcat ("/libtracker-data/local/", tests[i].test_name, NULL); + g_test_add (testpath, TestInfo, &tests[i], setup_local, test_sparql_query, teardown); + g_free (testpath); + } + /* run tests */ result = g_test_run (); |