Move repository registration out of AbstractDaemonTest#cloneProject

By moving out the repository registration, we can get the registered URI
which can be used to connect to the repository for both fetch and push.

This makes it possible to clone a remote repository to another remote
repository in the integration test and both of them are managed by
GitRepositoryManager.

Change-Id: Ic941ae184249bb9521da52350ae45b24cfe5f8c9
This commit is contained in:
Changcheng Xiao
2017-04-13 14:43:07 +02:00
parent e419d9ad71
commit 9a3b435080

View File

@@ -494,12 +494,22 @@ public abstract class AbstractDaemonTest {
protected TestRepository<InMemoryRepository> cloneProject(
Project.NameKey p, TestAccount testAccount) throws Exception {
return GitUtil.cloneProject(p, registerRepoConnection(p, testAccount));
}
/**
* Register a repository connection over the test protocol.
*
* @return a URI string that can be used to connect to this repository for both fetch and push.
* */
protected String registerRepoConnection(
Project.NameKey p, TestAccount testAccount) throws Exception {
InProcessProtocol.Context ctx =
new InProcessProtocol.Context(
reviewDbProvider, identifiedUserFactory, testAccount.getId(), p);
Repository repo = repoManager.openRepository(p);
toClose.add(repo);
return GitUtil.cloneProject(p, inProcessProtocol.register(ctx, repo).toString());
return inProcessProtocol.register(ctx, repo).toString();
}
protected void afterTest() throws Exception {