Search in sources :

Example 81 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class PipelineInstanceModelTest method shouldGetCurrentRevisionForMaterial.

@Test
public void shouldGetCurrentRevisionForMaterial() {
    MaterialRevisions revisions = new MaterialRevisions();
    HgMaterial material = MaterialsMother.hgMaterial();
    revisions.addRevision(material, HG_MATERIAL_MODIFICATION);
    PipelineInstanceModel model = PipelineInstanceModel.createPipeline("pipeline", -1, "label", BuildCause.createWithModifications(revisions, ""), new StageInstanceModels());
    assertThat(model.getCurrentRevision(material.config()).getRevision(), is("a087402bd2a7828a130c1bdf43f2d9ef8f48fd46"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 82 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class HgMultipleMaterialsTest method shouldIgnoreDestinationFolderWhenServerSide.

@Test
public void shouldIgnoreDestinationFolderWhenServerSide() throws Exception {
    HgMaterial material1 = repo.createMaterial("dest1");
    MaterialRevision materialRevision = new MaterialRevision(material1, material1.latestModification(pipelineDir, new TestSubprocessExecutionContext()));
    materialRevision.updateTo(pipelineDir, ProcessOutputStreamConsumer.inMemoryConsumer(), new TestSubprocessExecutionContext(true));
    assertThat(new File(pipelineDir, "dest1").exists(), is(false));
    assertThat(new File(pipelineDir, ".hg").exists(), is(true));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) Test(org.junit.Test)

Example 83 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class PipelineMaterialRevisionTest method shouldUsePassedInFROMRevisionWhenSCMMaterial.

@Test
public void shouldUsePassedInFROMRevisionWhenSCMMaterial() {
    Material material = new HgMaterial("http://some_server/repo", null);
    Modification latestModification = modification(new Date(), "123", null, null);
    Modification earlierModification = modification(new Date(), "23", null, null);
    PipelineMaterialRevision pmr = new PipelineMaterialRevision(9, new MaterialRevision(material, latestModification, earlierModification), null);
    Modification earlierThatEarlyModification = modification(new Date(), "13", null, null);
    pmr.useMaterialRevision(new MaterialRevision(material, latestModification, earlierThatEarlyModification));
    assertThat(pmr.getToModification(), is(latestModification));
    assertThat(pmr.getFromModification(), is(earlierThatEarlyModification));
    Modification laterThanLatestModification = modification(new Date(), "1234", null, null);
    pmr.useMaterialRevision(new MaterialRevision(material, laterThanLatestModification, earlierThatEarlyModification));
    assertThat(pmr.getToModification(), is(laterThanLatestModification));
    assertThat(pmr.getFromModification(), is(earlierThatEarlyModification));
    pmr.useMaterialRevision(new MaterialRevision(material, laterThanLatestModification, earlierModification));
    assertThat(pmr.getToModification(), is(laterThanLatestModification));
    assertThat(pmr.getFromModification(), is(earlierModification));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Date(java.util.Date) Test(org.junit.Test)

Example 84 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class MixedMultipleMaterialsTest method shouldGetLatestModifications.

@Test
public void shouldGetLatestModifications() throws Exception {
    HgMaterial hgMaterial = hgRepo.material();
    SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
    Materials materials = new Materials(hgMaterial, svnMaterial);
    MaterialRevisions revisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    assertThat(revisions.getMaterialRevision(0).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(0).getRevision(), is(new Modifications(hgRepo.latestModifications()).latestRevision(hgMaterial)));
    assertThat(revisions.getMaterialRevision(1).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(1).getRevision(), is(latestRevision(svnMaterial, pipelineDir, new TestSubprocessExecutionContext())));
    assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(2));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 85 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class HgTestRepo method commitAndPushFileWithContent.

public List<Modification> commitAndPushFileWithContent(String fileName, String comment, String content) throws Exception {
    File baseDir = temporaryFolder.newFolder();
    HgMaterial material = updateTo(baseDir);
    File file = new File(baseDir, fileName);
    FileUtils.writeStringToFile(file, content, UTF_8);
    return addCommitPush(material, comment, baseDir, file);
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) File(java.io.File)

Aggregations

HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)121 Test (org.junit.Test)107 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)34 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)29 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)23 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 Material (com.thoughtworks.go.domain.materials.Material)15 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)10 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)10 Date (java.util.Date)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)9 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)9 TimeProvider (com.thoughtworks.go.util.TimeProvider)8 Pagination (com.thoughtworks.go.server.util.Pagination)7 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)6 Modification (com.thoughtworks.go.domain.materials.Modification)6 File (java.io.File)6