Skip to content
Snippets Groups Projects
Commit c229e3a4 authored by Jack MacLauchlan CS2015's avatar Jack MacLauchlan CS2015
Browse files

issue repo tests

parent 73d71f20
No related branches found
No related tags found
No related merge requests found
package git;
import issueData.Issue;
import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
......@@ -55,28 +56,57 @@ class IssueRepoTests {
}
@Test
void testIssueBranchExistInvalidRepo() {
void testGetIssues() throws IOException {
populateRepoWithFakeData();
IssueRepo issueRepo = new IssueRepo();
assertThrows(IOException.class, () -> {
issueRepo.setGitDir("/!");
});
issueRepo.setGitDir(path.toAbsolutePath() + "/.git");
assertEquals(2, issueRepo.getIssues().size());
}
@Test
void testGetNicknames() throws IOException {
populateRepoWithFakeData();
IssueRepo issueRepo = new IssueRepo();
issueRepo.setGitDir(path.toAbsolutePath() + "/.git");
assertEquals(1, issueRepo.getNicknames().getIssueNicknames().size());
}
@Test
void testGetIssues() throws IOException {
void testWriteRepo() throws IOException {
populateRepoWithFakeData();
IssueRepo issueRepo = new IssueRepo();
issueRepo.setGitDir(path.toAbsolutePath() + "/.git");
assertEquals(2, issueRepo.getIssues().size());
issueRepo.getIssues().get(0).setStatus(false);
assertTrue(issueRepo.writeRepo("test writerepo"));
}
@Test
void testGetNicknames() throws IOException {
void testGetIssueWithHash() throws IOException {
populateRepoWithFakeData();
IssueRepo issueRepo = new IssueRepo();
issueRepo.setGitDir(path.toAbsolutePath() + "/.git");
assertEquals(1, issueRepo.getNicknames().getIssueNicknames().size());
assertTrue(issueRepo.getIssue("7a37cedc949c7be72767e9b7b008f33ba4b5136ff4a8bd4c6b00ca69b6ce51db").isPresent());
}
@Test
void testGetIssueWithNickname() throws IOException {
populateRepoWithFakeData();
IssueRepo issueRepo = new IssueRepo();
issueRepo.setGitDir(path.toAbsolutePath() + "/.git");
assertTrue(issueRepo.getIssue("issue").isPresent());
}
@Test
void testTwoIssueSameHash() throws IOException {
populateRepoWithFakeData();
IssueRepo issueRepo = new IssueRepo();
issueRepo.setGitDir(path.toAbsolutePath() + "/.git");
Issue duplciate = new Issue();
duplciate.setHash("7a37cedc949c7be72767e9b7b008f33ba4b5136ff4a8bd4c6b00ca69b6ce51db");
issueRepo.getIssues().add(duplciate);
assertThrows(IllegalStateException.class, () -> issueRepo.getIssue("7a37cedc949c7be72767e9b7b008f33ba4b5136ff4a8bd4c6b00ca69b6ce51db"));
}
private void populateRepoWithFakeData() {
......@@ -104,7 +134,5 @@ class IssueRepoTests {
assertEquals("Issue (orphan) branch created", commit.getFullMessage());
walk.dispose();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment