From 2ea85bfe371215ef21fcd528bc40fa57c48ee698 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 31 Oct 2012 16:38:03 -0400
Subject: [PATCH] Personal repositories must always be owned by the account the repo is stored in
---
tests/com/gitblit/tests/TicgitUtilsTest.java | 45 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/tests/com/gitblit/tests/TicgitUtilsTest.java b/tests/com/gitblit/tests/TicgitUtilsTest.java
index 25dba2c..74f9e44 100644
--- a/tests/com/gitblit/tests/TicgitUtilsTest.java
+++ b/tests/com/gitblit/tests/TicgitUtilsTest.java
@@ -15,23 +15,40 @@
*/
package com.gitblit.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.jgit.lib.Repository;
+import org.junit.Test;
import com.gitblit.models.RefModel;
import com.gitblit.models.TicketModel;
import com.gitblit.models.TicketModel.Comment;
import com.gitblit.utils.TicgitUtils;
-public class TicgitUtilsTest extends TestCase {
+public class TicgitUtilsTest {
- public void testTicGit() throws Exception {
+ @Test
+ public void testTicgitBranch() throws Exception {
Repository repository = GitBlitSuite.getTicgitRepository();
RefModel branch = TicgitUtils.getTicketsBranch(repository);
- assertTrue("Ticgit branch does not exist!", branch != null);
+ repository.close();
+ assertNotNull("Ticgit branch does not exist!", branch);
+
+ repository = GitBlitSuite.getHelloworldRepository();
+ branch = TicgitUtils.getTicketsBranch(repository);
+ repository.close();
+ assertNull("Ticgit branch exists!", branch);
+ }
+
+ @Test
+ public void testRetrieveTickets() throws Exception {
+ Repository repository = GitBlitSuite.getTicgitRepository();
List<TicketModel> ticketsA = TicgitUtils.getTickets(repository);
List<TicketModel> ticketsB = TicgitUtils.getTickets(repository);
repository.close();
@@ -47,8 +64,24 @@
Comment commentB = ticketB.comments.get(j);
assertTrue("Comments are not equal!", commentA.equals(commentB));
assertFalse(commentA.equals(""));
- assertTrue(commentA.hashCode() == commentA.text.hashCode());
+ assertEquals(commentA.hashCode(), commentA.text.hashCode());
}
}
+
+ repository = GitBlitSuite.getHelloworldRepository();
+ List<TicketModel> ticketsC = TicgitUtils.getTickets(repository);
+ repository.close();
+ assertNull(ticketsC);
+ }
+
+ @Test
+ public void testReadTicket() throws Exception {
+ Repository repository = GitBlitSuite.getTicgitRepository();
+ List<TicketModel> tickets = TicgitUtils.getTickets(repository);
+ TicketModel ticket = TicgitUtils
+ .getTicket(repository, tickets.get(tickets.size() - 1).name);
+ repository.close();
+ assertNotNull(ticket);
+ assertEquals("1206206148_add-attachment-to-ticket_138", ticket.name);
}
}
\ No newline at end of file
--
Gitblit v1.9.1