diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2022-05-01 18:46:04 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2022-05-01 19:44:47 +0200 |
commit | 31f489b4b53be04bd0e95767763a86ee73c53158 (patch) | |
tree | 5ad24d967ec31b0b49cbb913b17ed057ac021391 /tests/libtracker-sparql | |
parent | b84baa135e27478372a16dbecea22d04d31c84db (diff) | |
download | tracker-31f489b4b53be04bd0e95767763a86ee73c53158.tar.gz |
tests: Assert that cursors have the right connection assigned
Test for tracker_sparql_cursor_get_connection() returning the right
thing on cursor and statement tests.
Diffstat (limited to 'tests/libtracker-sparql')
-rw-r--r-- | tests/libtracker-sparql/tracker-cursor-test.c | 18 | ||||
-rw-r--r-- | tests/libtracker-sparql/tracker-statement-test.c | 6 |
2 files changed, 15 insertions, 9 deletions
diff --git a/tests/libtracker-sparql/tracker-cursor-test.c b/tests/libtracker-sparql/tracker-cursor-test.c index 38fa701e6..a3dabf1c4 100644 --- a/tests/libtracker-sparql/tracker-cursor-test.c +++ b/tests/libtracker-sparql/tracker-cursor-test.c @@ -141,12 +141,12 @@ query_and_compare_results (TrackerSparqlConnection *conn, GError *error = NULL; cursor_check = tracker_sparql_connection_query (direct, query, NULL, &error); - g_assert_no_error (error); + g_assert_true (tracker_sparql_cursor_get_connection (cursor_check) == direct); cursor = tracker_sparql_connection_query (conn, query, NULL, &error); - g_assert_no_error (error); + g_assert_true (tracker_sparql_cursor_get_connection (cursor) == conn); compare_cursors (cursor_check, cursor); @@ -183,9 +183,8 @@ test_tracker_sparql_query_iterate_error (gpointer fixture, const gchar *query = "bork bork bork"; cursor = tracker_sparql_connection_query (conn, query, NULL, &error); - /* tracker_sparql_query_iterate should return null on error */ - g_assert_true (!cursor); + g_assert_null (cursor); /* error should be set, along with its message, note: we don't * use g_assert_error() because the code does not match the @@ -209,9 +208,9 @@ test_tracker_sparql_query_iterate_empty (gpointer fixture, const gchar *query = "SELECT ?r WHERE {?r a nfo:FileDataObject; nao:identifier \"thisannotationdoesnotexist\"}"; cursor = tracker_sparql_connection_query (conn, query, NULL, &error); - g_assert_true (cursor); g_assert_no_error (error); + g_assert_true (tracker_sparql_cursor_get_connection (cursor) == conn); g_assert_false (tracker_sparql_cursor_next (cursor, NULL, NULL)); g_assert_true (tracker_sparql_cursor_get_n_columns (cursor) == 1); @@ -232,9 +231,9 @@ test_tracker_sparql_query_iterate_close_early (gpointer fixture, const gchar *query = "SELECT ?r WHERE {?r a nfo:FileDataObject}"; cursor = tracker_sparql_connection_query (conn, query, NULL, &error); - g_assert_true (cursor); g_assert_no_error (error); + g_assert_true (tracker_sparql_cursor_get_connection (cursor) == conn); g_assert_true (tracker_sparql_cursor_next (cursor, NULL, NULL)); @@ -254,14 +253,14 @@ async_query_cb (GObject *source_object, g_main_loop_quit (data->main_loop); cursor = tracker_sparql_connection_query_finish (conn, result, &error); - g_assert_no_error (error); g_assert_true (cursor != NULL); + g_assert_true (tracker_sparql_cursor_get_connection (cursor) == conn); cursor_check = tracker_sparql_connection_query (direct, data->query, NULL, &error); - g_assert_no_error (error); g_assert_true (cursor_check != NULL); + g_assert_true (tracker_sparql_cursor_get_connection (cursor_check) == direct); compare_cursors (cursor_check, cursor); @@ -501,6 +500,7 @@ test_tracker_sparql_cursor_next_async_query (TrackerSparqlConnection *conn, &error); g_assert_no_error (error); g_assert_true (cursor != NULL); + g_assert_true (tracker_sparql_cursor_get_connection (cursor) == conn); tracker_sparql_cursor_next_async (cursor, cancellable, @@ -543,6 +543,7 @@ test_tracker_sparql_cursor_get_variable_name (gpointer fixture, NULL, &error); g_assert_no_error (error); g_assert_true (cursor != NULL); + g_assert_true (tracker_sparql_cursor_get_connection (cursor) == conn); tracker_sparql_cursor_next (cursor, NULL, &error); g_assert_no_error (error); @@ -581,6 +582,7 @@ test_tracker_sparql_cursor_get_value_type (gpointer fixture, NULL, &error); g_assert_no_error (error); g_assert_true (cursor != NULL); + g_assert_true (tracker_sparql_cursor_get_connection (cursor) == conn); tracker_sparql_cursor_next (cursor, NULL, &error); g_assert_no_error (error); diff --git a/tests/libtracker-sparql/tracker-statement-test.c b/tests/libtracker-sparql/tracker-statement-test.c index 09cee6781..95f62cf69 100644 --- a/tests/libtracker-sparql/tracker-statement-test.c +++ b/tests/libtracker-sparql/tracker-statement-test.c @@ -212,6 +212,7 @@ query_statement (TestFixture *test_fixture, stmt = tracker_sparql_connection_query_statement (test_fixture->conn, query, NULL, &error); g_free (query); + g_assert_true (tracker_sparql_statement_get_connection (stmt) == test_fixture->conn); } g_assert_no_error (error); @@ -227,10 +228,11 @@ query_statement (TestFixture *test_fixture, } cursor = tracker_sparql_statement_execute (stmt, NULL, &error); - g_object_unref (stmt); if (test_info->output_file) { g_assert_no_error (error); + g_assert_true (tracker_sparql_cursor_get_connection (cursor) == + tracker_sparql_statement_get_connection (stmt)); path = g_build_filename (TOP_SRCDIR, "tests", "libtracker-sparql", test_info->output_file, NULL); @@ -240,6 +242,8 @@ query_statement (TestFixture *test_fixture, } else { g_assert_nonnull (error); } + + g_object_unref (stmt); } TrackerSparqlConnection * |