summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2017-12-27 23:48:20 +0000
committerSam Thursfield <sam@afuera.me.uk>2017-12-28 00:03:02 +0000
commitd73a4aa1192f49c99bf34eef9db33ef1e76d324d (patch)
tree7b400bdac29b14850a6591d1975c3fd1ed85f0a7
parent9debcfaba93781dbd14980518d31226af47de67e (diff)
downloadtracker-d73a4aa1192f49c99bf34eef9db33ef1e76d324d.tar.gz
tests/libtracker-data: Fix error tests in tracker-sparql-test
The logic for testing if the correct error message was returned was the wrong way round -- the comparer() function should return 0 if the message we got was OK, and 1 otherwise. Also we were calling strstr() backwards, we should look for the expected result inside the actual result and not the other way around. To complicate things, Tracker doesn't return error messages with newlines but on disk the expected output usually contains newlines as editors tend to add them. This makes the tests confusingly fail when they look correct, so we now chomp newlines off the end of the results file for expected error tests. With this fixed, the expected output needed some corrections.
-rw-r--r--tests/libtracker-data/error/query-error-1.out2
-rw-r--r--tests/libtracker-data/error/query-error-2.out2
-rw-r--r--tests/libtracker-data/tracker-sparql-test.c4
3 files changed, 5 insertions, 3 deletions
diff --git a/tests/libtracker-data/error/query-error-1.out b/tests/libtracker-data/error/query-error-1.out
index c989797be..715bd15f1 100644
--- a/tests/libtracker-data/error/query-error-1.out
+++ b/tests/libtracker-data/error/query-error-1.out
@@ -1 +1 @@
-nknown token
+syntax error, expected `{'
diff --git a/tests/libtracker-data/error/query-error-2.out b/tests/libtracker-data/error/query-error-2.out
index 731dccc3a..4a2b15244 100644
--- a/tests/libtracker-data/error/query-error-2.out
+++ b/tests/libtracker-data/error/query-error-2.out
@@ -1 +1 @@
-nknown property `http://www.w3.org/1999/02/22-rdf-syntax-ns#nonexisting'
+Unknown property `http://www.w3.org/1999/02/22-rdf-syntax-ns#nonexisting'
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index d69cf82c9..8744c8c93 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -162,7 +162,7 @@ const TestInfo tests[] = {
static int
strstr_i (const char *a, const char *b)
{
- return strstr (a, b) != NULL ? 1 : 0;
+ return strstr (b, a) == NULL ? 1 : 0;
}
static void
@@ -215,6 +215,8 @@ check_result (TrackerDBCursor *cursor,
} else if (test_info->expect_query_error) {
g_string_append (test_results, error->message);
g_clear_error (&error);
+
+ g_strchomp(results);
}
if (comparer (results, test_results->str)) {