|
|
@ -73,20 +73,19 @@ import org.junit.Test; |
|
|
|
public class BundleWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
public class BundleWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testWrite0() throws Exception { |
|
|
|
public void testWriteSingleRef() throws Exception { |
|
|
|
// Create a tiny bundle, (well one of) the first commits only
|
|
|
|
// Create a tiny bundle, (well one of) the first commits only
|
|
|
|
final byte[] bundle = makeBundle("refs/heads/firstcommit", |
|
|
|
final byte[] bundle = makeBundle("refs/heads/firstcommit", |
|
|
|
"42e4e7c5e507e113ebbb7801b16b52cf867b7ce1", null); |
|
|
|
"42e4e7c5e507e113ebbb7801b16b52cf867b7ce1", null); |
|
|
|
|
|
|
|
|
|
|
|
// Then we clone a new repo from that bundle and do a simple test. This
|
|
|
|
// Then we clone a new repo from that bundle and do a simple test. This
|
|
|
|
// makes sure
|
|
|
|
// makes sure we could read the bundle we created.
|
|
|
|
// we could read the bundle we created.
|
|
|
|
|
|
|
|
Repository newRepo = createBareRepository(); |
|
|
|
Repository newRepo = createBareRepository(); |
|
|
|
FetchResult fetchResult = fetchFromBundle(newRepo, bundle); |
|
|
|
FetchResult fetchResult = fetchFromBundle(newRepo, bundle); |
|
|
|
Ref advertisedRef = fetchResult |
|
|
|
Ref advertisedRef = fetchResult |
|
|
|
.getAdvertisedRef("refs/heads/firstcommit"); |
|
|
|
.getAdvertisedRef("refs/heads/firstcommit"); |
|
|
|
|
|
|
|
|
|
|
|
// We expect firstcommit to appear by id
|
|
|
|
// We expect first commit to appear by id
|
|
|
|
assertEquals("42e4e7c5e507e113ebbb7801b16b52cf867b7ce1", advertisedRef |
|
|
|
assertEquals("42e4e7c5e507e113ebbb7801b16b52cf867b7ce1", advertisedRef |
|
|
|
.getObjectId().name()); |
|
|
|
.getObjectId().name()); |
|
|
|
// ..and by name as the bundle created a new ref
|
|
|
|
// ..and by name as the bundle created a new ref
|
|
|
@ -94,13 +93,21 @@ public class BundleWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
.resolve("refs/heads/firstcommit").name()); |
|
|
|
.resolve("refs/heads/firstcommit").name()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Incremental bundle test |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testWrite1() throws Exception { |
|
|
|
public void testWriteHEAD() throws Exception { |
|
|
|
|
|
|
|
byte[] bundle = makeBundle("HEAD", |
|
|
|
|
|
|
|
"42e4e7c5e507e113ebbb7801b16b52cf867b7ce1", null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Repository newRepo = createBareRepository(); |
|
|
|
|
|
|
|
FetchResult fetchResult = fetchFromBundle(newRepo, bundle); |
|
|
|
|
|
|
|
Ref advertisedRef = fetchResult.getAdvertisedRef("HEAD"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals("42e4e7c5e507e113ebbb7801b16b52cf867b7ce1", advertisedRef |
|
|
|
|
|
|
|
.getObjectId().name()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void testIncrementalBundle() throws Exception { |
|
|
|
byte[] bundle; |
|
|
|
byte[] bundle; |
|
|
|
|
|
|
|
|
|
|
|
// Create a small bundle, an early commit
|
|
|
|
// Create a small bundle, an early commit
|
|
|
|