Search in sources :

Example 16 with RevisionContext

use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.

the class GitMaterialUpdaterTest method shouldConvertExistingRepoToFullRepoWhenShallowCloneIsOff.

@Test
public void shouldConvertExistingRepoToFullRepoWhenShallowCloneIsOff() throws IOException {
    String repositoryUrl = new GitTestRepo().projectRepositoryUrl();
    GitMaterial shallowMaterial = new GitMaterial(repositoryUrl, true);
    updateTo(shallowMaterial, new RevisionContext(REVISION_3), JobResult.Passed);
    assertThat(localRepoFor(shallowMaterial).isShallow(), is(true));
    GitMaterial fullMaterial = new GitMaterial(repositoryUrl, false);
    updateTo(fullMaterial, new RevisionContext(REVISION_4), JobResult.Passed);
    assertThat(localRepoFor(fullMaterial).isShallow(), is(false));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 17 with RevisionContext

use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.

the class GitMaterialUpdaterTest method shouldCreateBuildCommandUpdateToSpecificRevision.

@Test
public void shouldCreateBuildCommandUpdateToSpecificRevision() throws Exception {
    GitMaterial material = new GitMaterial(new GitTestRepo().projectRepositoryUrl(), true);
    File newFile = new File(workingDir, "second.txt");
    updateTo(material, new RevisionContext(REVISION_1, REVISION_0, 2), JobResult.Passed);
    assertThat(console.output(), containsString("Start updating files at revision " + REVISION_1.getRevision()));
    assertThat(newFile.exists(), is(false));
    console.clear();
    updateTo(material, new RevisionContext(REVISION_2, REVISION_1, 2), JobResult.Passed);
    assertThat(console.output(), containsString("Start updating files at revision " + REVISION_2.getRevision()));
    assertThat(newFile.exists(), is(true));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) File(java.io.File) Test(org.junit.Test)

Example 18 with RevisionContext

use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.

the class GitMaterialUpdaterTest method shouldNotDeleteAndRecheckoutDirectoryWhenBranchIsBlank.

/* This is to test the functionality of the private method isRepositoryChanged() */
@Test
public void shouldNotDeleteAndRecheckoutDirectoryWhenBranchIsBlank() throws Exception {
    String repositoryUrl = new GitTestRepo().projectRepositoryUrl();
    GitMaterial material = new GitMaterial(repositoryUrl, false);
    updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
    File shouldNotBeRemoved = new File(new File(workingDir, ".git"), "shouldNotBeRemoved");
    FileUtils.writeStringToFile(shouldNotBeRemoved, "Text file");
    GitMaterial material1 = new GitMaterial(repositoryUrl, " ");
    updateTo(material1, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
    assertThat("Should not have deleted whole folder", shouldNotBeRemoved.exists(), is(true));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 19 with RevisionContext

use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.

the class GitMaterialUpdaterTest method shouldNotDeleteAndRecheckoutDirectoryWhenUrlSame.

@Test
public void shouldNotDeleteAndRecheckoutDirectoryWhenUrlSame() throws Exception {
    GitMaterial material = new GitMaterial(new GitTestRepo().projectRepositoryUrl(), true);
    updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
    File shouldNotBeRemoved = new File(new File(workingDir, ".git"), "shouldNotBeRemoved");
    FileUtils.writeStringToFile(shouldNotBeRemoved, "gundi");
    assertThat(shouldNotBeRemoved.exists(), is(true));
    updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
    assertThat("Should not have deleted whole folder", shouldNotBeRemoved.exists(), is(true));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) File(java.io.File) Test(org.junit.Test)

Example 20 with RevisionContext

use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.

the class GitMaterialShallowCloneTest method shouldBeAbleToUpdateToRevisionNotFetched.

@Test
public void shouldBeAbleToUpdateToRevisionNotFetched() {
    GitMaterial material = new GitMaterial(repo.projectRepositoryUrl(), true);
    material.updateTo(inMemoryConsumer(), workingDir, new RevisionContext(REVISION_3, REVISION_2, 2), context());
    assertThat(localRepoFor(material).currentRevision(), is(REVISION_3.getRevision()));
    assertThat(localRepoFor(material).containsRevisionInBranch(REVISION_2), is(true));
    assertThat(localRepoFor(material).containsRevisionInBranch(REVISION_3), is(true));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) Test(org.junit.Test)

Aggregations

RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)20 Test (org.junit.Test)20 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)13 File (java.io.File)13 GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 GitSubmoduleRepos (com.thoughtworks.go.helper.GitSubmoduleRepos)6 Modification (com.thoughtworks.go.domain.materials.Modification)3 RegexMatcher (com.thoughtworks.go.matchers.RegexMatcher)2 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)1 TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)1 Matcher (java.util.regex.Matcher)1