Search in sources :

Example 1 with SysOutStreamConsumer

use of com.thoughtworks.go.mail.SysOutStreamConsumer in project gocd by gocd.

the class GitCommandTest method shouldBombForResetWorkingDirWhenSubmoduleUpdateFails.

@Test
public void shouldBombForResetWorkingDirWhenSubmoduleUpdateFails() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
    File submoduleFolder = submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitCommand gitWithSubmodule = new GitCommand(null, createTempWorkingDirectory(), GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null);
    gitWithSubmodule.clone(inMemoryConsumer(), submoduleRepos.mainRepo().getUrl());
    FileUtils.deleteDirectory(submoduleFolder);
    assertThat(submoduleFolder.exists(), is(false));
    try {
        gitWithSubmodule.resetWorkingDir(new SysOutStreamConsumer(), new StringRevision("HEAD"));
        fail("should have failed for non 0 return code");
    } catch (Exception e) {
        assertThat(e.getMessage(), new RegexMatcher(String.format("[Cc]lone of '%s' into submodule path '((.*)[\\/])?sub1' failed", Pattern.quote(submoduleFolder.getAbsolutePath()))));
    }
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) SysOutStreamConsumer(com.thoughtworks.go.mail.SysOutStreamConsumer) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) RegexMatcher(com.thoughtworks.go.matchers.RegexMatcher) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) File(java.io.File) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException)

Example 2 with SysOutStreamConsumer

use of com.thoughtworks.go.mail.SysOutStreamConsumer in project gocd by gocd.

the class GitCommandTest method shouldBombForResettingFailure.

@Test
public void shouldBombForResettingFailure() throws IOException {
    try {
        git.resetWorkingDir(new SysOutStreamConsumer(), new StringRevision("abcdef"));
        fail("should have failed for non 0 return code");
    } catch (Exception e) {
        assertThat(e.getMessage(), is(String.format("git reset failed for [%s]", gitLocalRepoDir)));
    }
}
Also used : SysOutStreamConsumer(com.thoughtworks.go.mail.SysOutStreamConsumer) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException)

Aggregations

StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)2 SysOutStreamConsumer (com.thoughtworks.go.mail.SysOutStreamConsumer)2 IOException (java.io.IOException)2 ExpectedException (org.junit.rules.ExpectedException)2 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)1 GitSubmoduleRepos (com.thoughtworks.go.helper.GitSubmoduleRepos)1 RegexMatcher (com.thoughtworks.go.matchers.RegexMatcher)1 File (java.io.File)1