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



commit 8ead0cd11a6f51c352325cd63e650092f0a84295
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 447b264..d4bfdaf 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]