summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2011-05-05 16:29:26 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2011-05-06 14:32:14 -0400
commit2e8e46b5512f4e137368ecb3377cc8d7acb2e52b (patch)
tree69a58fa7bfc8ee6c0c1f3380d38c8d683694721e
parenta7efd0d30918022e6221ee7cafb63705b3e3c528 (diff)
downloadtelepathy-logger-2e8e46b5512f4e137368ecb3377cc8d7acb2e52b.tar.gz
Test that Pidgin store is robust to empty file
-rw-r--r--tests/dbus/test-tpl-log-store-pidgin.c47
-rw-r--r--tests/logs/purple/icq/12345678/87654321/2010-02-06.130032+0000GMT.htmlbin0 -> 938 bytes
-rw-r--r--tests/logs/purple/icq/12345678/87654321/2010-02-07.130033+0000GMT.html0
3 files changed, 47 insertions, 0 deletions
diff --git a/tests/dbus/test-tpl-log-store-pidgin.c b/tests/dbus/test-tpl-log-store-pidgin.c
index f8563da..5dd3c3e 100644
--- a/tests/dbus/test-tpl-log-store-pidgin.c
+++ b/tests/dbus/test-tpl-log-store-pidgin.c
@@ -21,6 +21,7 @@
#define ACCOUNT_PATH_JABBER TP_ACCOUNT_OBJECT_PATH_BASE "foo/jabber/baz"
#define ACCOUNT_PATH_IRC TP_ACCOUNT_OBJECT_PATH_BASE "foo/irc/baz"
+#define ACCOUNT_PATH_ICQ TP_ACCOUNT_OBJECT_PATH_BASE "foo/icq/baz"
typedef struct
{
@@ -472,6 +473,36 @@ test_search_new (PidginTestCaseFixture *fixture,
tpl_log_manager_search_free (l);
}
+static void
+test_get_events_for_empty_file (PidginTestCaseFixture *fixture,
+ gconstpointer user_data)
+{
+ GList *l = NULL;
+ TplEntity *entity;
+ GDate *date;
+
+ entity = tpl_entity_new ("87654321", TPL_ENTITY_CONTACT, NULL, NULL);
+
+ /* Check with empty file */
+ date = g_date_new_dmy (7, 2, 2010);
+
+ l = log_store_pidgin_get_events_for_date (TPL_LOG_STORE (fixture->store),
+ fixture->account, entity, TPL_EVENT_MASK_ANY, date);
+
+ g_assert_cmpint (g_list_length (l), ==, 0);
+ g_date_free (date);
+
+ /* Check with file that contains only 1 dot */
+ date = g_date_new_dmy (6, 2, 2010);
+
+ l = log_store_pidgin_get_events_for_date (TPL_LOG_STORE (fixture->store),
+ fixture->account, entity, TPL_EVENT_MASK_ANY, date);
+
+ g_assert_cmpint (g_list_length (l), ==, 0);
+ g_date_free (date);
+
+ g_object_unref (entity);
+}
static void
setup_debug (void)
@@ -563,6 +594,22 @@ main (int argc, char **argv)
PidginTestCaseFixture, params,
setup, test_get_dates_irc, teardown);
+ /* Empty file */
+ params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
+ (GDestroyNotify) tp_g_value_slice_free);
+ g_assert (params != NULL);
+
+ l = g_list_prepend (l, params);
+
+ g_hash_table_insert (params, "account",
+ tp_g_value_slice_new_static_string ("12345678"));
+ g_hash_table_insert (params, "account-path",
+ tp_g_value_slice_new_static_string (ACCOUNT_PATH_ICQ));
+
+ g_test_add ("/log-store-pidgin/get-event-for-empty-file",
+ PidginTestCaseFixture, params,
+ setup, test_get_events_for_empty_file, teardown);
+
retval = g_test_run ();
g_list_foreach (l, (GFunc) g_hash_table_unref, NULL);
diff --git a/tests/logs/purple/icq/12345678/87654321/2010-02-06.130032+0000GMT.html b/tests/logs/purple/icq/12345678/87654321/2010-02-06.130032+0000GMT.html
new file mode 100644
index 0000000..8e87f42
--- /dev/null
+++ b/tests/logs/purple/icq/12345678/87654321/2010-02-06.130032+0000GMT.html
Binary files differ
diff --git a/tests/logs/purple/icq/12345678/87654321/2010-02-07.130033+0000GMT.html b/tests/logs/purple/icq/12345678/87654321/2010-02-07.130033+0000GMT.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/logs/purple/icq/12345678/87654321/2010-02-07.130033+0000GMT.html