StatusCommandTest: Open Git in try-with-resource

Change-Id: Id13ad9fa3157d0479da12fb8184437be3ca8c948
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
This commit is contained in:
David Pursehouse 2016-02-05 17:03:25 +09:00
parent 96ff311049
commit 6aa619ec5c
1 changed files with 85 additions and 83 deletions

View File

@ -61,8 +61,7 @@ public class StatusCommandTest extends RepositoryTestCase {
@Test
public void testEmptyStatus() throws NoWorkTreeException,
GitAPIException {
Git git = new Git(db);
try (Git git = new Git(db)) {
Status stat = git.status().call();
assertEquals(0, stat.getAdded().size());
assertEquals(0, stat.getChanged().size());
@ -71,11 +70,12 @@ public void testEmptyStatus() throws NoWorkTreeException,
assertEquals(0, stat.getRemoved().size());
assertEquals(0, stat.getUntracked().size());
}
}
@Test
public void testDifferentStates() throws IOException,
NoFilepatternException, GitAPIException {
Git git = new Git(db);
try (Git git = new Git(db)) {
writeTrashFile("a", "content of a");
writeTrashFile("b", "content of b");
writeTrashFile("c", "content of c");
@ -130,11 +130,12 @@ public void testDifferentStates() throws IOException,
assertEquals(1, stat.getUntrackedFolders().size());
assertTrue(stat.getUntrackedFolders().contains("sub"));
}
}
@Test
public void testDifferentStatesWithPaths() throws IOException,
NoFilepatternException, GitAPIException {
Git git = new Git(db);
try (Git git = new Git(db)) {
writeTrashFile("a", "content of a");
writeTrashFile("D/b", "content of b");
writeTrashFile("D/c", "content of c");
@ -167,3 +168,4 @@ public void testDifferentStatesWithPaths() throws IOException,
assertEquals(Sets.of("a", "D/b", "D/D/d"), stat.getModified());
}
}
}