Search in sources :

Example 26 with RevisionContext

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

the class GitMaterialUpdaterTest method shouldDeleteAndRecheckoutDirectoryWhenUrlChanges.

@Test
public void shouldDeleteAndRecheckoutDirectoryWhenUrlChanges() throws Exception {
    updateTo(new GitMaterial(new GitTestRepo(temporaryFolder).projectRepositoryUrl(), true), new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
    File shouldBeRemoved = new File(workingDir, "shouldBeRemoved");
    shouldBeRemoved.createNewFile();
    assertThat(shouldBeRemoved.exists(), is(true));
    String repositoryUrl = new GitTestRepo(temporaryFolder).projectRepositoryUrl();
    GitMaterial material = new GitMaterial(repositoryUrl, true);
    updateTo(material, new RevisionContext(REVISION_4), JobResult.Passed);
    assertThat(localRepoFor(material).workingRepositoryUrl().forCommandline(), is(repositoryUrl));
    assertThat(shouldBeRemoved.exists(), is(false));
}
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 27 with RevisionContext

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

the class HgMaterialUpdaterTest method shouldUpdateToSpecificRevision.

@Test
public void shouldUpdateToSpecificRevision() throws Exception {
    updateTo(hgMaterial, new RevisionContext(REVISION_0), JobResult.Passed);
    File end2endFolder = new File(workingFolder, "end2end");
    assertThat(end2endFolder.listFiles().length, is(3));
    updateTo(hgMaterial, new RevisionContext(REVISION_1), JobResult.Passed);
    assertThat(end2endFolder.listFiles().length, is(4));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) File(java.io.File) Test(org.junit.Test)

Example 28 with RevisionContext

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

the class HgMaterialUpdaterTest method shouldLogRepoInfoToConsoleOutWithoutFolder.

@Test
public void shouldLogRepoInfoToConsoleOutWithoutFolder() throws Exception {
    updateTo(hgMaterial, new RevisionContext(new StringRevision("0")), JobResult.Passed);
    assertThat(console.output(), containsString(format("Start updating %s at revision %s from %s", "files", "0", hgMaterial.getUrl())));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Test(org.junit.Test)

Example 29 with RevisionContext

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

the class HgMaterialUpdaterTest method shouldPullNewChangesFromRemoteBeforeUpdating.

@Test
public void shouldPullNewChangesFromRemoteBeforeUpdating() throws Exception {
    File newWorkingFolder = temporaryFolder.newFolder("newWorkingFolder");
    updateTo(hgMaterial, new RevisionContext(REVISION_0), JobResult.Passed);
    String repositoryUrl = hgTestRepo.projectRepositoryUrl();
    HgMaterial material = MaterialsMother.hgMaterial(repositoryUrl);
    assertThat(material.getUrl(), is(hgMaterial.getUrl()));
    updateTo(material, new RevisionContext(REVISION_0), JobResult.Passed, newWorkingFolder);
    hgTestRepo.commitAndPushFile("SomeDocumentation.txt", "whatever");
    List<Modification> modification = hgMaterial.latestModification(workingFolder, new TestSubprocessExecutionContext());
    StringRevision revision = new StringRevision(modification.get(0).getRevision());
    updateTo(material, new RevisionContext(revision), JobResult.Passed, newWorkingFolder);
    assertThat(console.output(), containsString("Start updating files at revision " + revision.getRevision()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) StringContains.containsString(org.hamcrest.core.StringContains.containsString) File(java.io.File) Test(org.junit.Test)

Example 30 with RevisionContext

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

the class HgMaterialUpdaterTest method shouldNotDeleteAndRecheckoutDirectoryUnlessUrlChanges.

@Test
public void shouldNotDeleteAndRecheckoutDirectoryUnlessUrlChanges() throws Exception {
    String repositoryUrl = new HgTestRepo(temporaryFolder).projectRepositoryUrl();
    HgMaterial material = MaterialsMother.hgMaterial(repositoryUrl);
    updateTo(material, new RevisionContext(REVISION_0), JobResult.Passed);
    File shouldNotBeRemoved = new File(workingFolder, "shouldBeRemoved");
    shouldNotBeRemoved.createNewFile();
    assertThat(shouldNotBeRemoved.exists(), is(true));
    updateTo(material, new RevisionContext(REVISION_2), JobResult.Passed);
    assert (MaterialUrl.sameUrl(material.getUrl(), repositoryUrl));
    assertThat(shouldNotBeRemoved.exists(), is(true));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringContains.containsString(org.hamcrest.core.StringContains.containsString) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) File(java.io.File) Test(org.junit.Test)

Aggregations

RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)43 Test (org.junit.Test)37 File (java.io.File)23 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)17 GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)9 GitSubmoduleRepos (com.thoughtworks.go.helper.GitSubmoduleRepos)6 Modification (com.thoughtworks.go.domain.materials.Modification)5 Test (org.junit.jupiter.api.Test)4 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)3 StringContains.containsString (org.hamcrest.core.StringContains.containsString)3 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)2 TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)2 HgTestRepo (com.thoughtworks.go.helper.HgTestRepo)2 RegexMatcher (com.thoughtworks.go.matchers.RegexMatcher)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)1 AgentSubprocessExecutionContext (com.thoughtworks.go.domain.materials.AgentSubprocessExecutionContext)1 Revision (com.thoughtworks.go.domain.materials.Revision)1 SvnTestRepo (com.thoughtworks.go.helper.SvnTestRepo)1