diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-05-14 13:43:52 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-05-14 13:43:52 +0100 |
commit | 253a26f460b1c303648cf3a7398c50ad278b24a9 (patch) | |
tree | 6f7992ba3b02b5ce8293e021bfd2e82f763506c2 | |
parent | 746739fab55dbc0493ea4a29d68cf545e3f151dc (diff) | |
download | libgdata-wip/pwithnall/walbottle.tar.gz |
tests: WIP work to add Walbottle support for unit testingwip/pwithnall/walbottle
-rw-r--r-- | gdata/tests/tasks.c | 33 | ||||
-rw-r--r-- | gdata/tests/tasks.schema.json | 72 |
2 files changed, 105 insertions, 0 deletions
diff --git a/gdata/tests/tasks.c b/gdata/tests/tasks.c index 4f0f895a..cc2f8cc9 100644 --- a/gdata/tests/tasks.c +++ b/gdata/tests/tasks.c @@ -25,6 +25,8 @@ #include "common.h" #include "gdata-dummy-authorizer.h" +#include "tasks.schema.json.h" + static UhmServer *mock_server = NULL; /* owned */ #undef CLIENT_ID /* from common.h */ @@ -422,6 +424,35 @@ test_task_parser_minimal (void) g_object_unref (task); } +/* Test the task parser with generated JSON. */ +static void +test_task_parser_generated (void) +{ + guint i; + + for (i = 0; i < G_N_ELEMENTS (json_instances); i++) { + GDataTasksTask *task = NULL; /* owned */ + GError *error = NULL; + + task = GDATA_TASKS_TASK (gdata_parsable_new_from_json (GDATA_TYPE_TASKS_TASK, + json_instances[i].json, -1, + &error)); + + if (json_instances[i].is_valid) { + g_assert_no_error (error); + g_assert (GDATA_IS_TASKS_TASK (task)); + gdata_test_compare_kind (GDATA_ENTRY (task), "tasks#task", NULL); + + g_clear_object (&task); + } else { + g_assert (error != NULL); /* TODO */ + g_assert (task == NULL); + + g_clear_error (&error); + } + } +} + /* Test the task parser with a maximal number of properties specified. */ static void test_task_parser_normal (void) @@ -1412,6 +1443,8 @@ main (int argc, char *argv[]) g_test_add_func ("/tasks/task/escaping", test_task_escaping); g_test_add_func ("/tasks/task/parser/minimal", test_task_parser_minimal); + g_test_add_func ("/tasks/task/parser/generated", + test_task_parser_generated); g_test_add_func ("/tasks/task/parser/normal", test_task_parser_normal); g_test_add_func ("/tasks/tasklist/properties", diff --git a/gdata/tests/tasks.schema.json b/gdata/tests/tasks.schema.json new file mode 100644 index 00000000..9039ac75 --- /dev/null +++ b/gdata/tests/tasks.schema.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Task", + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "id": { + "type": "string", + "minLength": 1 + }, + "updated": { + "type": "string", + "minLength": 1, + "format": "date-time" + }, + "etag": { + "type": "string", + "minLength": 1 + }, + "selfLink": { + "type": "string", + "minLength": 1, + "format": "uri" + }, + "kind": { + "type": "string", + "minLength": 1, + "enum": [ + "tasks#task" + ] + }, + "parent": { + "type": "string" + }, + "position": { + "type": "string", + "pattern": "[0-9]+" + }, + "notes": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "needsAction" + ] + }, + "due": { + "type": "string", + "minLength": 1, + "format": "date-time" + }, + "completed": { + "type": "string", + "minLength": 1, + "format": "date-time" + }, + "deleted": { + "type": "boolean" + }, + "hidden": { + "type": "boolean" + } + }, + "required": [ + "id", + "kind", + "updated" + ] +} |