Browse Source

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
stable-4.9
Shawn Pearce 8 years ago
parent
commit
da5a27cd4e
  1. 36
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java

36
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 {

Loading…
Cancel
Save