use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitOriginSubmodulesTest method testRewriteUrl.
@Test
public void testRewriteUrl() throws Exception {
Path base = Files.createTempDirectory("testRewriteUrl");
GitRepository r1 = createRepoWithFoo(base, "r1");
GitRepository r2 = createRepoWithFoo(base, "r2");
GitRepository r3 = GitRepository.newBareRepo(base.resolve("testRewriteUrl").resolve("r3"), getGitEnv(), false, Duration.ofMinutes(1), false).init();
r3.fetch("file://" + r1.getGitDir(), false, true, ImmutableList.of("refs/heads/*:refs/heads/*"), false);
String primaryBranch = r2.getPrimaryBranch();
OptionsBuilder options = new OptionsBuilder().setConsole(new TestingConsole()).setOutputRootToTmpDir();
options.git = new GitOptions(options.general) {
@Override
public String rewriteSubmoduleUrl(String url) {
return r3.getGitDir().toString();
}
};
skylark = new SkylarkTestExecutor(options);
r2.simpleCommand("submodule", "add", "-f", "--name", "r1", "file://" + r1.getWorkTree(), "r1");
commit(r2, "adding r3->r1 submodule");
// Nuke r1 to verify r3 is read
MoreFiles.deleteRecursively(r1.getGitDir());
GitOrigin origin = origin("file://" + r2.getGitDir(), primaryBranch);
GitRevision main = origin.resolve(primaryBranch);
origin.newReader(Glob.ALL_FILES, authoring).checkout(main, checkoutDir);
FileSubjects.assertThatPath(checkoutDir).containsFiles(GITMODULES).containsFile("r1/foo", "1");
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class SubmodulesInDestinationTest method setup.
@Before
public void setup() throws Exception {
repoGitDir = Files.createTempDirectory("SubmodulesInDestinationTest-repoGitDir");
workdir = Files.createTempDirectory("workdir");
git("init", "--bare", repoGitDir.toString());
console = new TestingConsole();
options = new OptionsBuilder().setConsole(console).setOutputRootToTmpDir();
options.gitDestination.committerEmail = "commiter@email";
options.gitDestination.committerName = "Bara Kopi";
destinationFiles = Glob.createGlob(ImmutableList.of("**"));
url = "file://" + repoGitDir;
skylark = new SkylarkTestExecutor(options);
submodule = GitRepository.newBareRepo(Files.createTempDirectory("gitdir"), getGitEnv(), /*verbose=*/
true, DEFAULT_TIMEOUT, /*noVerify=*/
false).withWorkTree(Files.createTempDirectory("worktree")).init();
primaryBranch = submodule.getPrimaryBranch();
Files.write(submodule.getWorkTree().resolve("foo"), new byte[] { 1 });
submodule.add().files("foo").run();
submodule.simpleCommand("commit", "-m", "dummy commit");
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GerritApiTransportWithCheckerTest method setup.
@Before
public void setup() throws Exception {
console = new TestingConsole();
delegate = Mockito.mock(GerritApiTransport.class);
checker = Mockito.mock(Checker.class);
transport = new GerritApiTransportWithChecker(delegate, new ApiChecker(checker, console));
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitHubApiTransportImplTest method runTestThrowsHttpResponseException.
private void runTestThrowsHttpResponseException(Callable<?> c) throws Exception {
HttpResponseException ex = new HttpResponseException.Builder(STATUS_CODE, ERROR_MESSAGE, new HttpHeaders()).build();
httpTransport = createMockHttpTransport(ex);
transport = new GitHubApiTransportImpl(repo, httpTransport, "store", new TestingConsole());
try {
c.call();
fail();
} catch (GitHubApiException e) {
assertThat(e.getHttpCode()).isEqualTo(STATUS_CODE);
assertThat(e.getError()).isNull();
}
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitHubApiTransportImplTest method runTestThrowsIOException.
private void runTestThrowsIOException(Callable<?> c) throws Exception {
IOException ioException = new IOException();
httpTransport = createMockHttpTransport(ioException);
transport = new GitHubApiTransportImpl(repo, httpTransport, "store", new TestingConsole());
try {
c.call();
fail();
} catch (RepoException e) {
assertThat(e.getCause()).isEqualTo(ioException);
}
}
Aggregations