[PATCH JGit 10/19] moved test up to a higher level to test actual functionality

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

 



From: mike.gaffney <mike.gaffney@xxxxxxxxxxxxxx>

---
 .../org/spearce/jgit/lib/ObjectDirectoryTest.java  |   32 ++++++++++++++++----
 .../UpdateDirectoryBasedPacksInfoCacheTest.java    |   30 ------------------
 2 files changed, 26 insertions(+), 36 deletions(-)
 delete mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
index 8e4d8e5..4ac62fa 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
@@ -1,6 +1,8 @@
 package org.spearce.jgit.lib;
 
 import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
@@ -69,12 +71,7 @@ public void testListLocalPacksNotCreated() throws Exception {
 	}
 	
 	public void testListLocalPacksWhenThereIsAPack() throws Exception {
-		createTestDir();
-		File packsDir = new File(testDir, "pack");
-		packsDir.mkdirs();
-		
-		JGitTestUtil.copyFile(TEST_PACK, new File(packsDir, TEST_PACK.getName()));
-		JGitTestUtil.copyFile(TEST_IDX, new File(packsDir, TEST_IDX.getName()));
+		createSamplePacksDir();
 
 		ObjectDirectory od = new ObjectDirectory(testDir);
 		List<PackFile> localPacks = od.listLocalPacks();
@@ -82,6 +79,20 @@ public void testListLocalPacksWhenThereIsAPack() throws Exception {
 		assertEquals(TEST_PACK.getName(), localPacks.get(0).getPackFile().getName());
 	}
 	
+	public void testUpdateInfoCacheCreatesPacksFile() throws Exception {
+		createSamplePacksDir();
+
+		ObjectDirectory od = new ObjectDirectory(testDir);
+		od.create();
+		od.updateInfoCache();
+		
+		String expectedContents = new PacksFileContentsCreator(od.listLocalPacks()).toString();
+		File packsFile = new File(od.getDirectory(), "info/packs");
+
+		assertTrue(packsFile.exists());
+		assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
+	}
+	
 	public boolean deleteDir(File dir) {
         if (dir.isDirectory()) {
             String[] children = dir.list();
@@ -100,5 +111,14 @@ public boolean deleteDir(File dir) {
 	private void createTestDir(){
 		testDir.mkdir();
 	}
+
+	private void createSamplePacksDir() throws IOException {
+		createTestDir();
+		File packsDir = new File(testDir, "pack");
+		packsDir.mkdirs();
+		
+		JGitTestUtil.copyFile(TEST_PACK, new File(packsDir, TEST_PACK.getName()));
+		JGitTestUtil.copyFile(TEST_IDX, new File(packsDir, TEST_IDX.getName()));
+	}
 	
 }
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java
deleted file mode 100644
index f5163e4..0000000
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.spearce.jgit.lib;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.spearce.jgit.util.JGitTestUtil;
-
-public class UpdateDirectoryBasedPacksInfoCacheTest extends TestCase {
-	private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
-	private static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + ".pack");
-	private static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + ".idx");
-	
-	public void testCreatesTheFileAndPutsTheContentsIn() throws Exception {
-		List<PackFile> packs = new ArrayList<PackFile>();
-		packs.add(new PackFile(TEST_IDX, TEST_PACK));
-		
-		File packsFile = File.createTempFile(UpdateDirectoryBasedPacksInfoCacheTest.class.getSimpleName(), "tstdata");
-		packsFile.deleteOnExit();
-		
-		String expectedContents = new PacksFileContentsCreator(packs).toString();
-		
-		new UpdateDirectoryBasedPacksInfoCache(packs, packsFile).execute();
-		
-		assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
-	}
-
-}
-- 
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]