Test getLatestCommit function
authorReto Buerki <reet@codelabs.ch>
Tue, 20 Mar 2012 11:07:54 +0000 (12:07 +0100)
committerReto Buerki <reet@codelabs.ch>
Tue, 20 Mar 2012 11:07:54 +0000 (12:07 +0100)
src/ch/codelabs/gitter/test/CommitDbAdapterTest.java

index fc09d01..964fcba 100644 (file)
@@ -34,7 +34,7 @@ public class CommitDbAdapterTest extends AndroidTestCase {
         * Insert commit into database.
         */
        public void testInsertCommit() {
-               final String testHash = "fc7a3c29b985d90f271c7b9ea9f095729759799c";
+               final String testHash = "abca3c29b985d90f271c7b9ea9f095729759799c";
                final CommitDbAdapter commitDbAdapter = new CommitDbAdapter(
                                getContext());
                commitDbAdapter.open();
@@ -59,9 +59,9 @@ public class CommitDbAdapterTest extends AndroidTestCase {
                assertEquals("testdata", c.getString(c
                                .getColumnIndexOrThrow(CommitDbAdapter.KEY_CONTENT)));
 
+               /* Test 'read' status */
                commitDbAdapter.setReadStatus(id, true);
 
-               /* Re-fetch commit and assert read status */
                Cursor i = commitDbAdapter.fetchCommit(id);
                assertEquals(1,
                                i.getInt(i.getColumnIndexOrThrow(CommitDbAdapter.KEY_READ)));
@@ -71,6 +71,10 @@ public class CommitDbAdapterTest extends AndroidTestCase {
                assertEquals(0,
                                i.getInt(i.getColumnIndexOrThrow(CommitDbAdapter.KEY_READ)));
 
+               /* Test latest commit getter */
+               i = commitDbAdapter.getLatestCommit();
+               assertEquals(testHash,
+                               i.getString(i.getColumnIndexOrThrow(CommitDbAdapter.KEY_HASH)));
 
                commitDbAdapter.deleteCommit(id);
                c.close();