[tracker] tests: Do not compare/assert expected errors' text in tracker-sparql-test
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tests: Do not compare/assert expected errors' text in tracker-sparql-test
- Date: Tue, 2 Oct 2018 23:05:12 +0000 (UTC)
commit 7c0c2e100175fca6dfd4ac9a49c7819ebbc25894
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Sep 22 23:00:16 2018 +0200
tests: Do not compare/assert expected errors' text in tracker-sparql-test
While testing for error existence makes sense, expecting specific error
messages makes tests non forward-compatible to possible changes.
tests/libtracker-data/tracker-sparql-test.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index d127e67b3..960388f18 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -155,28 +155,19 @@ const TestInfo tests[] = {
{ NULL }
};
-static int
-strstr_i (const char *a, const char *b)
-{
- return strstr (b, a) == NULL ? 1 : 0;
-}
-
static void
check_result (TrackerDBCursor *cursor,
const TestInfo *test_info,
const gchar *results_filename,
GError *error)
{
- int (*comparer) (const char *a, const char *b);
GString *test_results;
gchar *results;
GError *nerror = NULL;
if (test_info->expect_query_error) {
- comparer = strstr_i;
g_assert (error != NULL);
} else {
- comparer = strcmp;
g_assert_no_error (error);
}
@@ -209,13 +200,15 @@ check_result (TrackerDBCursor *cursor,
g_string_append (test_results, "\n");
}
} else if (test_info->expect_query_error) {
- g_string_append (test_results, error->message);
- g_clear_error (&error);
-
- g_strchomp(results);
+ g_assert (error != NULL && error->domain == TRACKER_SPARQL_ERROR);
+ g_string_free (test_results, TRUE);
+ g_free (results);
+ return;
}
- if (comparer (results, test_results->str)) {
+ g_assert_no_error (error);
+
+ if (strcmp (results, test_results->str) != 0) {
/* print result difference */
gchar *quoted_results;
gchar *command_line;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]