Browse Source

Cleanup existing tests

Renamed and restructured tests for improved clarity.

Bug: 479266
Change-Id: Ic9d05ddf722bddd148fa9d9c19248dd53d97f1e4
Signed-off-by: René Scheibe <rene.scheibe@gmail.com>
stable-5.1
René Scheibe 6 years ago
parent
commit
dbe01e8852
  1. 28
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java

28
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java

@ -179,31 +179,29 @@ public class ResetCommandTest extends RepositoryTestCase {
} }
@Test @Test
public void testHardResetWithConflicts_DoOverWriteUntrackedFile() public void testHardResetWithConflicts_OverwriteUntrackedFile() throws Exception {
throws JGitInternalException,
AmbiguousObjectException, IOException, GitAPIException {
setupRepository(); setupRepository();
git.rm().setCached(true).addFilepattern("a.txt").call(); git.rm().setCached(true).addFilepattern("a.txt").call();
assertTrue(new File(db.getWorkTree(), "a.txt").exists()); assertTrue(new File(db.getWorkTree(), "a.txt").exists());
git.reset().setMode(ResetType.HARD).setRef(Constants.HEAD)
.call(); git.reset().setMode(ResetType.HARD).setRef(Constants.HEAD).call();
assertTrue(new File(db.getWorkTree(), "a.txt").exists()); assertTrue(new File(db.getWorkTree(), "a.txt").exists());
assertEquals("content", read(new File(db.getWorkTree(), "a.txt"))); assertEquals("content", read(new File(db.getWorkTree(), "a.txt")));
} }
@Test @Test
public void testHardResetWithConflicts_DoDeleteFileFolderConflicts() public void testHardResetWithConflicts_DeleteFileFolderConflict() throws Exception {
throws JGitInternalException,
AmbiguousObjectException, IOException, GitAPIException {
setupRepository(); setupRepository();
writeTrashFile("d/c.txt", "x");
git.add().addFilepattern("d/c.txt").call();
FileUtils.delete(new File(db.getWorkTree(), "d"), FileUtils.RECURSIVE);
writeTrashFile("d", "y");
git.reset().setMode(ResetType.HARD).setRef(Constants.HEAD) writeTrashFile("dir-or-file/c.txt", "content");
.call(); git.add().addFilepattern("dir-or-file/c.txt").call();
assertFalse(new File(db.getWorkTree(), "d").exists());
FileUtils.delete(new File(db.getWorkTree(), "dir-or-file"), FileUtils.RECURSIVE);
writeTrashFile("dir-or-file", "content");
git.reset().setMode(ResetType.HARD).setRef(Constants.HEAD).call();
assertFalse(new File(db.getWorkTree(), "dir-or-file").exists());
} }
@Test @Test

Loading…
Cancel
Save