[tracker/sparql-refactor] libtracker-data: Add update error test case
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sparql-refactor] libtracker-data: Add update error test case
- Date: Wed, 31 Mar 2010 13:41:50 +0000 (UTC)
commit 1437d6edb083753eb970eba3b5d65e938eda4fb2
Author: Jürg Billeter <j bitron ch>
Date: Wed Mar 31 15:36:31 2010 +0200
libtracker-data: Add update error test case
tests/libtracker-data/error/Makefile.am | 7 ++++++-
.../libtracker-data/error/update-error-1.ontology | 16 ++++++++++++++++
tests/libtracker-data/error/update-error-1.rq | 5 +++++
.../libtracker-data/error/update-error-query-1.rq | 5 +++++
tests/libtracker-data/tracker-sparql-test.c | 19 +++++++++++++------
5 files changed, 45 insertions(+), 7 deletions(-)
---
diff --git a/tests/libtracker-data/error/Makefile.am b/tests/libtracker-data/error/Makefile.am
index 29d23fd..b98aeaa 100644
--- a/tests/libtracker-data/error/Makefile.am
+++ b/tests/libtracker-data/error/Makefile.am
@@ -7,4 +7,9 @@ EXTRA_DIST = query-error-1.ontology \
query-error-2.ontology \
query-error-2.out \
query-error-2.rq \
- query-error-2.ttl
+ query-error-2.ttl \
+ update-error-1.ontology \
+ update-error-1.rq \
+ update-error-query-1.out \
+ update-error-query-1.rq
+
diff --git a/tests/libtracker-data/error/update-error-1.ontology b/tests/libtracker-data/error/update-error-1.ontology
new file mode 100644
index 0000000..c041ffd
--- /dev/null
+++ b/tests/libtracker-data/error/update-error-1.ontology
@@ -0,0 +1,16 @@
+ prefix example: <http://example.com/> .
+ prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+ prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+ prefix tracker: <http://www.tracker-project.org/ontologies/tracker#> .
+ prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+example: a tracker:Namespace ;
+ tracker:prefix "example" .
+
+example:A a rdfs:Class ;
+ rdfs:subClassOf rdfs:Resource .
+
+rdf:value a rdf:Property ;
+ rdfs:domain example:A ;
+ rdfs:range xsd:string .
+
diff --git a/tests/libtracker-data/error/update-error-1.rq b/tests/libtracker-data/error/update-error-1.rq
new file mode 100644
index 0000000..6a4d59d
--- /dev/null
+++ b/tests/libtracker-data/error/update-error-1.rq
@@ -0,0 +1,5 @@
+INSERT {
+ example:foo a example:A .
+ example:foo rdf:value "foo" .
+ example:foo rdf:nonexisting "bar" .
+}
diff --git a/tests/libtracker-data/error/update-error-query-1.out b/tests/libtracker-data/error/update-error-query-1.out
new file mode 100644
index 0000000..e69de29
diff --git a/tests/libtracker-data/error/update-error-query-1.rq b/tests/libtracker-data/error/update-error-query-1.rq
new file mode 100644
index 0000000..82e520e
--- /dev/null
+++ b/tests/libtracker-data/error/update-error-query-1.rq
@@ -0,0 +1,5 @@
+SELECT ?s ?o
+WHERE {
+ ?s rdf:value ?o
+}
+
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index 81578c0..3344444 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -37,7 +37,8 @@ typedef struct _TestInfo TestInfo;
struct _TestInfo {
const gchar *test_name;
const gchar *data;
- gboolean expect_error;
+ gboolean expect_query_error;
+ gboolean expect_update_error;
};
const TestInfo tests[] = {
@@ -95,9 +96,10 @@ const TestInfo tests[] = {
{ "subqueries/subqueries-1", "subqueries/data-1", FALSE },
{ "subqueries/subqueries-union-1", "subqueries/data-1", FALSE },
/* Bracket error after WHERE */
- { "error/query-error-1", "error/query-error-1", TRUE },
+ { "error/query-error-1", "error/query-error-1", TRUE, FALSE },
/* Unknown property */
- { "error/query-error-2", "error/query-error-2", TRUE },
+ { "error/query-error-2", "error/query-error-2", TRUE, FALSE },
+ { "error/update-error-query-1", "error/update-error-1", FALSE, TRUE },
{ "turtle/turtle-query-001", "turtle/turtle-data-001", FALSE },
{ "turtle/turtle-query-002", "turtle/turtle-data-002", FALSE },
@@ -160,7 +162,12 @@ test_sparql_query (gconstpointer test_data)
tracker_data_begin_db_transaction ();
tracker_data_update_sparql (data, &error);
tracker_data_commit_db_transaction ();
- g_assert_no_error (error);
+ if (test_info->expect_update_error) {
+ g_assert (error != NULL);
+ g_clear_error (&error);
+ } else {
+ g_assert_no_error (error);
+ }
g_free (data);
}
@@ -180,7 +187,7 @@ test_sparql_query (gconstpointer test_data)
result_set = tracker_data_query_sparql (query, &error);
- if (test_info->expect_error) {
+ if (test_info->expect_query_error) {
comparer = strstr_i;
g_assert (error != NULL);
} else {
@@ -231,7 +238,7 @@ test_sparql_query (gconstpointer test_data)
}
g_object_unref (result_set);
- } else if (test_info->expect_error) {
+ } else if (test_info->expect_query_error) {
g_string_append (test_results, error->message);
g_clear_error (&error);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]