[tracker/binary-log-2: 30/44] libtracker-db: Added more journal reader unit tests



commit dc10d5be5e0d544247800a6854ea29547ce839e2
Author: Martyn Russell <martyn lanedo com>
Date:   Wed Jan 6 16:28:49 2010 +0000

    libtracker-db: Added more journal reader unit tests

 tests/libtracker-db/tracker-db-journal.c |  115 +++++++++++++++++++++++++++++-
 1 files changed, 114 insertions(+), 1 deletions(-)
---
diff --git a/tests/libtracker-db/tracker-db-journal.c b/tests/libtracker-db/tracker-db-journal.c
index 40a7649..c64f172 100644
--- a/tests/libtracker-db/tracker-db-journal.c
+++ b/tests/libtracker-db/tracker-db-journal.c
@@ -136,6 +136,8 @@ test_read_functions (void)
 	gchar *path;
 	gboolean result;
 	TrackerDBJournalEntryType type;
+	guint32 id, s_id, p_id, o_id;
+	const gchar *uri, *str;
 
 	path = g_build_filename (TOP_SRCDIR, "tests", "libtracker-db", "tracker-store.journal", NULL);
 
@@ -148,12 +150,123 @@ test_read_functions (void)
 	type = tracker_db_journal_reader_get_type ();
 	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_START);
 
+	/* First transaction */
 	result = tracker_db_journal_reader_next (&error);
 	g_assert_no_error (error);
 	g_assert_cmpint (result, ==, TRUE);
 
-	/* FIXME: unfinished */
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_START_TRANSACTION);
+
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_RESOURCE);
+
+	result = tracker_db_journal_reader_get_resource (&id, &uri);
+	g_assert_cmpint (result, ==, TRUE);
+	g_assert_cmpint (id, ==, 12);
+	g_assert_cmpstr (uri, ==, "http://resource";);
+
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_RESOURCE);
+
+	result = tracker_db_journal_reader_get_resource (&id, &uri);
+	g_assert_cmpint (result, ==, TRUE);
+	g_assert_cmpint (id, ==, 13);
+	g_assert_cmpstr (uri, ==, "http://predicate";);
+
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_RESOURCE);
+
+	result = tracker_db_journal_reader_get_resource (&id, &uri);
+	g_assert_cmpint (result, ==, TRUE);
+	g_assert_cmpint (id, ==, 14);
+	g_assert_cmpstr (uri, ==, "http://resource";);
+
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_DELETE_STATEMENT_ID);
+
+	result = tracker_db_journal_reader_get_statement_id (&s_id, &p_id, &o_id);
+	g_assert_cmpint (result, ==, TRUE);
+	g_assert_cmpint (s_id, ==, 12);
+	g_assert_cmpint (p_id, ==, 13);
+	g_assert_cmpint (o_id, ==, 14);
+
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_END_TRANSACTION);
+
+	/* Second transaction */
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_START_TRANSACTION);
+
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_RESOURCE);
+
+	result = tracker_db_journal_reader_get_resource (&id, &uri);
+	g_assert_cmpint (result, ==, TRUE);
+	g_assert_cmpint (id, ==, 15);
+	g_assert_cmpstr (uri, ==, "http://resource";);
+
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_RESOURCE);
+
+	result = tracker_db_journal_reader_get_resource (&id, &uri);
+	g_assert_cmpint (result, ==, TRUE);
+	g_assert_cmpint (id, ==, 16);
+	g_assert_cmpstr (uri, ==, "http://predicate";);
+
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_INSERT_STATEMENT);
+
+	result = tracker_db_journal_reader_get_statement (&s_id, &p_id, &str);
+	g_assert_cmpint (result, ==, TRUE);
+	g_assert_cmpint (s_id, ==, 15);
+	g_assert_cmpint (p_id, ==, 16);
+	g_assert_cmpstr (str, ==, "test");
+
+	result = tracker_db_journal_reader_next (&error);
+	g_assert_no_error (error);
+	g_assert_cmpint (result, ==, TRUE);
+
+	type = tracker_db_journal_reader_get_type ();
+	g_assert_cmpint (type, ==, TRACKER_DB_JOURNAL_END_TRANSACTION);
 
+	/* Shutdown */
 	result = tracker_db_journal_reader_shutdown ();
 	g_assert_cmpint (result, ==, TRUE);
 



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