aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2018-08-28 13:57:52 -0700
committerIvan Frade <ifrade@google.com>2018-09-14 08:52:23 -0700
commitcb4de02e5e7502705ef52264eb76d03a90c950d1 (patch)
tree0f41545e84be5d5e24691c4bc84993d655806e04 /org.eclipse.jgit.test
parentd6d4cc3ab88820a0768f4f1fc2a066cf6ecbb25f (diff)
downloadjgit-cb4de02e5e7502705ef52264eb76d03a90c950d1.tar.gz
jgit-cb4de02e5e7502705ef52264eb76d03a90c950d1.zip
Move ls-refs parsing code to the ProtocolV2Parser
Fetch code has been moved to a ProtocolV2Parser, but ls-refs code is still in UploadPack. Moving it to the parser makes it easier to test, keeps the parsing together and makes the two commands follow similar structure. Change-Id: I573ce543e804ddeb9f83303b4af250b7cddc8cad Signed-off-by: Ivan Frade <ifrade@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
index 4d1150844c..c2e8b5b621 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
@@ -45,6 +45,7 @@ package org.eclipse.jgit.transport;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -333,4 +334,60 @@ public class ProtocolV2ParserTest {
testRepo.getRepository().getRefDatabase());
}
+ @Test
+ public void testLsRefsMinimalReq() throws IOException {
+ PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
+ PacketLineIn.END);
+
+ ProtocolV2Parser parser = new ProtocolV2Parser(
+ ConfigBuilder.getDefault());
+ LsRefsV2Request req = parser.parseLsRefsRequest(pckIn);
+ assertFalse(req.getPeel());
+ assertFalse(req.getSymrefs());
+ assertEquals(0, req.getRefPrefixes().size());
+ }
+
+ @Test
+ public void testLsRefsSymrefs() throws IOException {
+ PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM, "symrefs",
+ PacketLineIn.END);
+
+ ProtocolV2Parser parser = new ProtocolV2Parser(
+ ConfigBuilder.getDefault());
+ LsRefsV2Request req = parser.parseLsRefsRequest(pckIn);
+ assertFalse(req.getPeel());
+ assertTrue(req.getSymrefs());
+ assertEquals(0, req.getRefPrefixes().size());
+
+ }
+
+ @Test
+ public void testLsRefsPeel() throws IOException {
+ PacketLineIn pckIn = formatAsPacketLine(
+ PacketLineIn.DELIM,
+ "peel",
+ PacketLineIn.END);
+
+ ProtocolV2Parser parser = new ProtocolV2Parser(
+ ConfigBuilder.getDefault());
+ LsRefsV2Request req = parser.parseLsRefsRequest(pckIn);
+ assertTrue(req.getPeel());
+ assertFalse(req.getSymrefs());
+ assertEquals(0, req.getRefPrefixes().size());
+ }
+
+ @Test
+ public void testLsRefsRefPrefixes() throws IOException {
+ PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
+ "ref-prefix refs/for", "ref-prefix refs/heads",
+ PacketLineIn.END);
+
+ ProtocolV2Parser parser = new ProtocolV2Parser(
+ ConfigBuilder.getDefault());
+ LsRefsV2Request req = parser.parseLsRefsRequest(pckIn);
+ assertFalse(req.getPeel());
+ assertFalse(req.getSymrefs());
+ assertEquals(2, req.getRefPrefixes().size());
+ assertThat(req.getRefPrefixes(), hasItems("refs/for", "refs/heads"));
+ }
}