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"));
}
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));
}
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));
}
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));
}
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);
}
Aggregations