summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2017-07-12 16:15:56 -0700
committerShawn Pearce <spearce@spearce.org>2017-08-17 15:06:51 -0700
commitda5a27cd4eddcc59980f48a120028982fc2ac616 (patch)
tree51ee99eae4820268b938a5ef3cc4e7d1fa044088 /org.eclipse.jgit.test
parent9da26a5a1ae098e92fc6a0b7097e63e90a57c9aa (diff)
downloadjgit-da5a27cd4eddcc59980f48a120028982fc2ac616.tar.gz
jgit-da5a27cd4eddcc59980f48a120028982fc2ac616.zip
reftable: namespace unit tests
Add additional test cases for looking up entries within a namespace such as refs/heads/ or refs/tags/, where the seek is passed a name that ends with '/'. Change-Id: I5f944de7518cd0090374bddba48d4dd3955a8d72
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java
index 5c19af3004..ac37c73ca8 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java
@@ -74,6 +74,7 @@ import org.junit.Test;
public class ReftableTest {
private static final String MASTER = "refs/heads/master";
+ private static final String NEXT = "refs/heads/next";
private static final String V1_0 = "refs/tags/v1.0";
private Stats stats;
@@ -273,6 +274,41 @@ public class ReftableTest {
}
}
+ @Test
+ public void namespaceNotFound() throws IOException {
+ Ref exp = ref(MASTER, 1);
+ ReftableReader t = read(write(exp));
+ try (RefCursor rc = t.seekRef("refs/changes/")) {
+ assertFalse(rc.next());
+ }
+ try (RefCursor rc = t.seekRef("refs/tags/")) {
+ assertFalse(rc.next());
+ }
+ }
+
+ @Test
+ public void namespaceHeads() throws IOException {
+ Ref master = ref(MASTER, 1);
+ Ref next = ref(NEXT, 2);
+ Ref v1 = tag(V1_0, 3, 4);
+
+ ReftableReader t = read(write(master, next, v1));
+ try (RefCursor rc = t.seekRef("refs/tags/")) {
+ assertTrue(rc.next());
+ assertEquals(V1_0, rc.getRef().getName());
+ assertFalse(rc.next());
+ }
+ try (RefCursor rc = t.seekRef("refs/heads/")) {
+ assertTrue(rc.next());
+ assertEquals(MASTER, rc.getRef().getName());
+
+ assertTrue(rc.next());
+ assertEquals(NEXT, rc.getRef().getName());
+
+ assertFalse(rc.next());
+ }
+ }
+
@SuppressWarnings("boxing")
@Test
public void indexScan() throws IOException {