aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2017-07-21 12:40:33 -0700
committerShawn Pearce <spearce@spearce.org>2017-08-17 15:06:51 -0700
commit7da2fe6be88cb6696b4d3e59189298daa2a2816a (patch)
treee60ef7c9759289375e2d052269750a8d8e3d6633 /org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage
parente8e8041e837faa950c433a0e4b73ba9873afb1b2 (diff)
downloadjgit-7da2fe6be88cb6696b4d3e59189298daa2a2816a.tar.gz
jgit-7da2fe6be88cb6696b4d3e59189298daa2a2816a.zip
reftable: lookup by ObjectId unit tests
Change-Id: Ic819a04e285094e271435dcd027d8006e5897785
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java62
1 files changed, 62 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 3abd3d3950..b53853b2e5 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
@@ -515,6 +515,68 @@ public class ReftableTest {
}
}
+ @SuppressWarnings("boxing")
+ @Test
+ public void byObjectIdOneRefNoIndex() throws IOException {
+ List<Ref> refs = new ArrayList<>();
+ for (int i = 1; i <= 200; i++) {
+ refs.add(ref(String.format("refs/heads/%02d", i), i));
+ }
+ refs.add(ref("refs/heads/master", 100));
+
+ ReftableReader t = read(write(refs));
+ assertEquals(0, stats.objIndexSize());
+
+ try (RefCursor rc = t.byObjectId(id(42))) {
+ assertTrue("has 42", rc.next());
+ assertEquals("refs/heads/42", rc.getRef().getName());
+ assertEquals(id(42), rc.getRef().getObjectId());
+ assertFalse(rc.next());
+ }
+ try (RefCursor rc = t.byObjectId(id(100))) {
+ assertTrue("has 100", rc.next());
+ assertEquals("refs/heads/100", rc.getRef().getName());
+ assertEquals(id(100), rc.getRef().getObjectId());
+
+ assertTrue("has master", rc.next());
+ assertEquals("refs/heads/master", rc.getRef().getName());
+ assertEquals(id(100), rc.getRef().getObjectId());
+
+ assertFalse(rc.next());
+ }
+ }
+
+ @SuppressWarnings("boxing")
+ @Test
+ public void byObjectIdOneRefWithIndex() throws IOException {
+ List<Ref> refs = new ArrayList<>();
+ for (int i = 1; i <= 5200; i++) {
+ refs.add(ref(String.format("refs/heads/%02d", i), i));
+ }
+ refs.add(ref("refs/heads/master", 100));
+
+ ReftableReader t = read(write(refs));
+ assertTrue(stats.objIndexSize() > 0);
+
+ try (RefCursor rc = t.byObjectId(id(42))) {
+ assertTrue("has 42", rc.next());
+ assertEquals("refs/heads/42", rc.getRef().getName());
+ assertEquals(id(42), rc.getRef().getObjectId());
+ assertFalse(rc.next());
+ }
+ try (RefCursor rc = t.byObjectId(id(100))) {
+ assertTrue("has 100", rc.next());
+ assertEquals("refs/heads/100", rc.getRef().getName());
+ assertEquals(id(100), rc.getRef().getObjectId());
+
+ assertTrue("has master", rc.next());
+ assertEquals("refs/heads/master", rc.getRef().getName());
+ assertEquals(id(100), rc.getRef().getObjectId());
+
+ assertFalse(rc.next());
+ }
+ }
+
@Test
public void unpeeledDoesNotWrite() {
try {