Improve getLatestCommit test
authorReto Buerki <reet@codelabs.ch>
Tue, 20 Mar 2012 22:57:27 +0000 (23:57 +0100)
committerReto Buerki <reet@codelabs.ch>
Tue, 20 Mar 2012 23:07:16 +0000 (00:07 +0100)
src/ch/codelabs/gitter/test/CommitDbAdapterTest.java

index 67295c6..f556f81 100644 (file)
@@ -34,20 +34,20 @@ public class CommitDbAdapterTest extends AndroidTestCase {
         * Insert commit into database.
         */
        public void testInsertCommit() {
-               final String testHash = "abca3c29b985d90f271c7b9ea9f095729759799c";
+               final String testHash1 = "c669e1928dec2a9251a819ca40f32beed9e280ec";
                final String testMail = "doe@example.com";
                final CommitDbAdapter commitDbAdapter = new CommitDbAdapter(
                                getContext());
                commitDbAdapter.open();
 
-               final long id = commitDbAdapter.insertCommit("Update TODO", testHash,
+               long id = commitDbAdapter.insertCommit("Update TODO", testHash1,
                                "John Doe", testMail, "http://1.com/abc", "testdata");
 
                final Cursor c = commitDbAdapter.fetchAllCommits();
                assertTrue(c.getCount() > 0);
 
                c.moveToLast();
-               assertEquals(testHash,
+               assertEquals(testHash1,
                                c.getString(c.getColumnIndexOrThrow(CommitDbAdapter.KEY_HASH)));
                assertEquals(0,
                                c.getInt(c.getColumnIndexOrThrow(CommitDbAdapter.KEY_READ)));
@@ -55,8 +55,8 @@ public class CommitDbAdapterTest extends AndroidTestCase {
                                c.getString(c.getColumnIndexOrThrow(CommitDbAdapter.KEY_TITLE)));
                assertEquals("John Doe", c.getString(c
                                .getColumnIndexOrThrow(CommitDbAdapter.KEY_AUTHOR)));
-               assertEquals(testMail, c.getString(c
-                               .getColumnIndexOrThrow(CommitDbAdapter.KEY_EMAIL)));
+               assertEquals(testMail,
+                               c.getString(c.getColumnIndexOrThrow(CommitDbAdapter.KEY_EMAIL)));
                assertEquals("http://1.com/abc", c.getString(c
                                .getColumnIndexOrThrow(CommitDbAdapter.KEY_DIFFLINK)));
                assertEquals("testdata", c.getString(c
@@ -74,10 +74,15 @@ public class CommitDbAdapterTest extends AndroidTestCase {
                assertEquals(0,
                                i.getInt(i.getColumnIndexOrThrow(CommitDbAdapter.KEY_READ)));
 
-               /* Test latest commit getter */
+               commitDbAdapter.deleteCommit(id);
+
+               /* Test latest commit getter, insert another commit first */
+               final String testHash2 = "abca3c29b985d90f271c7b9ea9f095729759799c";
+               id = commitDbAdapter.insertCommit("Update TODO", testHash2, "John Doe",
+                               testMail, "http://1.com/abc", "testdata");
                i = commitDbAdapter.getLatestCommit();
                assertTrue(i.getCount() == 1);
-               assertEquals(testHash,
+               assertEquals(testHash2,
                                i.getString(i.getColumnIndexOrThrow(CommitDbAdapter.KEY_HASH)));
 
                commitDbAdapter.deleteCommit(id);