use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class GitCommandTest method shouldOutputSubmoduleRevisionsAfterUpdate.
@Test
public void shouldOutputSubmoduleRevisionsAfterUpdate() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitCommand gitWithSubmodule = new GitCommand(null, createTempWorkingDirectory(), GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null);
gitWithSubmodule.clone(inMemoryConsumer(), submoduleRepos.mainRepo().getUrl());
InMemoryStreamConsumer outConsumer = new InMemoryStreamConsumer();
gitWithSubmodule.resetWorkingDir(outConsumer, new StringRevision("HEAD"));
Matcher matcher = Pattern.compile(".*^\\s[a-f0-9A-F]{40} sub1 \\(heads/master\\)$.*", Pattern.MULTILINE | Pattern.DOTALL).matcher(outConsumer.getAllOutput());
assertThat(matcher.matches(), is(true));
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class GitCommandTest method shouldCloneFromMasterWhenNoBranchIsSpecified.
@Test
public void shouldCloneFromMasterWhenNoBranchIsSpecified() {
InMemoryStreamConsumer output = inMemoryConsumer();
git.clone(output, repoUrl);
CommandLine commandLine = CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(gitLocalRepoDir);
commandLine.run(output, "");
assertThat(output.getStdOut(), Is.is("* master"));
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class GitCommandTest method shouldRetrieveSubmoduleUrls.
@Test
public void shouldRetrieveSubmoduleUrls() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitCommand gitWithSubmodule = new GitCommand(null, createTempWorkingDirectory(), GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null);
InMemoryStreamConsumer outputStreamConsumer = inMemoryConsumer();
gitWithSubmodule.clone(outputStreamConsumer, submoduleRepos.mainRepo().getUrl());
gitWithSubmodule.fetchAndResetToHead(outputStreamConsumer);
gitWithSubmodule.updateSubmoduleWithInit(outputStreamConsumer);
Map<String, String> urls = gitWithSubmodule.submoduleUrls();
assertThat(urls.size(), is(1));
assertThat(urls.containsKey("sub1"), is(true));
assertThat(urls.get("sub1"), endsWith(SUBMODULE));
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class GitCommandTest method shouldCloneFromBranchWhenMaterialPointsToABranch.
@Test
public void shouldCloneFromBranchWhenMaterialPointsToABranch() throws IOException {
gitLocalRepoDir = createTempWorkingDirectory();
git = new GitCommand(null, gitLocalRepoDir, BRANCH, false, new HashMap<>(), null);
GitCommand branchedGit = new GitCommand(null, gitLocalRepoDir, BRANCH, false, new HashMap<>(), null);
branchedGit.clone(inMemoryConsumer(), gitFooBranchBundle.projectRepositoryUrl());
InMemoryStreamConsumer output = inMemoryConsumer();
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(gitLocalRepoDir).run(output, "");
assertThat(output.getStdOut(), Is.is("* foo"));
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class HgCommandTest method shouldThrowExceptionIfUpdateFails.
@Test(expected = RuntimeException.class)
public void shouldThrowExceptionIfUpdateFails() throws Exception {
InMemoryStreamConsumer output = ProcessOutputStreamConsumer.inMemoryConsumer();
// delete repository in order to fail the hg pull command
assertThat(FileUtils.deleteQuietly(serverRepo), is(true));
// now hg pull will fail and throw an exception
hgCommand.updateTo(new StringRevision("tip"), output);
}
Aggregations