|
|
@ -126,7 +126,7 @@ public class ReftableTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void estimateCurrentBytesOneRef() throws IOException { |
|
|
|
public void estimateCurrentBytesOneRef() throws IOException { |
|
|
|
Ref exp = ref(MASTER, 1); |
|
|
|
Ref exp = ref(MASTER, 1); |
|
|
|
int expBytes = 24 + 4 + 5 + 3 + MASTER.length() + 20 + 68; |
|
|
|
int expBytes = 24 + 4 + 5 + 4 + MASTER.length() + 20 + 68; |
|
|
|
|
|
|
|
|
|
|
|
byte[] table; |
|
|
|
byte[] table; |
|
|
|
ReftableConfig cfg = new ReftableConfig(); |
|
|
|
ReftableConfig cfg = new ReftableConfig(); |
|
|
@ -155,7 +155,7 @@ public class ReftableTest { |
|
|
|
cfg.setIndexObjects(false); |
|
|
|
cfg.setIndexObjects(false); |
|
|
|
cfg.setMaxIndexLevels(1); |
|
|
|
cfg.setMaxIndexLevels(1); |
|
|
|
|
|
|
|
|
|
|
|
int expBytes = 139654; |
|
|
|
int expBytes = 147860; |
|
|
|
byte[] table; |
|
|
|
byte[] table; |
|
|
|
ReftableWriter writer = new ReftableWriter().setConfig(cfg); |
|
|
|
ReftableWriter writer = new ReftableWriter().setConfig(cfg); |
|
|
|
try (ByteArrayOutputStream buf = new ByteArrayOutputStream()) { |
|
|
|
try (ByteArrayOutputStream buf = new ByteArrayOutputStream()) { |
|
|
@ -174,7 +174,7 @@ public class ReftableTest { |
|
|
|
public void oneIdRef() throws IOException { |
|
|
|
public void oneIdRef() throws IOException { |
|
|
|
Ref exp = ref(MASTER, 1); |
|
|
|
Ref exp = ref(MASTER, 1); |
|
|
|
byte[] table = write(exp); |
|
|
|
byte[] table = write(exp); |
|
|
|
assertEquals(24 + 4 + 5 + 3 + MASTER.length() + 20 + 68, table.length); |
|
|
|
assertEquals(24 + 4 + 5 + 4 + MASTER.length() + 20 + 68, table.length); |
|
|
|
|
|
|
|
|
|
|
|
ReftableReader t = read(table); |
|
|
|
ReftableReader t = read(table); |
|
|
|
try (RefCursor rc = t.allRefs()) { |
|
|
|
try (RefCursor rc = t.allRefs()) { |
|
|
@ -203,7 +203,7 @@ public class ReftableTest { |
|
|
|
public void oneTagRef() throws IOException { |
|
|
|
public void oneTagRef() throws IOException { |
|
|
|
Ref exp = tag(V1_0, 1, 2); |
|
|
|
Ref exp = tag(V1_0, 1, 2); |
|
|
|
byte[] table = write(exp); |
|
|
|
byte[] table = write(exp); |
|
|
|
assertEquals(24 + 4 + 5 + 2 + V1_0.length() + 40 + 68, table.length); |
|
|
|
assertEquals(24 + 4 + 5 + 3 + V1_0.length() + 40 + 68, table.length); |
|
|
|
|
|
|
|
|
|
|
|
ReftableReader t = read(table); |
|
|
|
ReftableReader t = read(table); |
|
|
|
try (RefCursor rc = t.allRefs()) { |
|
|
|
try (RefCursor rc = t.allRefs()) { |
|
|
@ -224,7 +224,7 @@ public class ReftableTest { |
|
|
|
Ref exp = sym(HEAD, MASTER); |
|
|
|
Ref exp = sym(HEAD, MASTER); |
|
|
|
byte[] table = write(exp); |
|
|
|
byte[] table = write(exp); |
|
|
|
assertEquals( |
|
|
|
assertEquals( |
|
|
|
24 + 4 + 5 + 2 + HEAD.length() + 1 + MASTER.length() + 68, |
|
|
|
24 + 4 + 5 + 2 + HEAD.length() + 2 + MASTER.length() + 68, |
|
|
|
table.length); |
|
|
|
table.length); |
|
|
|
|
|
|
|
|
|
|
|
ReftableReader t = read(table); |
|
|
|
ReftableReader t = read(table); |
|
|
@ -281,7 +281,7 @@ public class ReftableTest { |
|
|
|
String name = "refs/heads/gone"; |
|
|
|
String name = "refs/heads/gone"; |
|
|
|
Ref exp = newRef(name); |
|
|
|
Ref exp = newRef(name); |
|
|
|
byte[] table = write(exp); |
|
|
|
byte[] table = write(exp); |
|
|
|
assertEquals(24 + 4 + 5 + 2 + name.length() + 68, table.length); |
|
|
|
assertEquals(24 + 4 + 5 + 3 + name.length() + 68, table.length); |
|
|
|
|
|
|
|
|
|
|
|
ReftableReader t = read(table); |
|
|
|
ReftableReader t = read(table); |
|
|
|
try (RefCursor rc = t.allRefs()) { |
|
|
|
try (RefCursor rc = t.allRefs()) { |
|
|
@ -425,13 +425,14 @@ public class ReftableTest { |
|
|
|
|
|
|
|
|
|
|
|
writer.finish(); |
|
|
|
writer.finish(); |
|
|
|
byte[] table = buffer.toByteArray(); |
|
|
|
byte[] table = buffer.toByteArray(); |
|
|
|
assertEquals(245, table.length); |
|
|
|
assertEquals(247, table.length); |
|
|
|
|
|
|
|
|
|
|
|
ReftableReader t = read(table); |
|
|
|
ReftableReader t = read(table); |
|
|
|
try (RefCursor rc = t.allRefs()) { |
|
|
|
try (RefCursor rc = t.allRefs()) { |
|
|
|
assertTrue(rc.next()); |
|
|
|
assertTrue(rc.next()); |
|
|
|
assertEquals(MASTER, rc.getRef().getName()); |
|
|
|
assertEquals(MASTER, rc.getRef().getName()); |
|
|
|
assertEquals(id(1), rc.getRef().getObjectId()); |
|
|
|
assertEquals(id(1), rc.getRef().getObjectId()); |
|
|
|
|
|
|
|
assertEquals(1, rc.getUpdateIndex()); |
|
|
|
|
|
|
|
|
|
|
|
assertTrue(rc.next()); |
|
|
|
assertTrue(rc.next()); |
|
|
|
assertEquals(NEXT, rc.getRef().getName()); |
|
|
|
assertEquals(NEXT, rc.getRef().getName()); |
|
|
@ -636,7 +637,7 @@ public class ReftableTest { |
|
|
|
writer.finish(); |
|
|
|
writer.finish(); |
|
|
|
fail("expected BlockSizeTooSmallException"); |
|
|
|
fail("expected BlockSizeTooSmallException"); |
|
|
|
} catch (BlockSizeTooSmallException e) { |
|
|
|
} catch (BlockSizeTooSmallException e) { |
|
|
|
assertEquals(84, e.getMinimumBlockSize()); |
|
|
|
assertEquals(85, e.getMinimumBlockSize()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|