[tracker] tests/libtracker-data: Fix error tests in tracker-sparql-test



commit d73a4aa1192f49c99bf34eef9db33ef1e76d324d
Author: Sam Thursfield <sam afuera me uk>
Date:   Wed Dec 27 23:48:20 2017 +0000

    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.

 tests/libtracker-data/error/query-error-1.out |    2 +-
 tests/libtracker-data/error/query-error-2.out |    2 +-
 tests/libtracker-data/tracker-sparql-test.c   |    4 +++-
 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 c989797..715bd15 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 731dccc..4a2b152 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 d69cf82..8744c8c 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)) {


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