use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldChooseTheRevisionFromSecondInAComplexSituation.
@Test
public void shouldChooseTheRevisionFromSecondInAComplexSituation() throws Exception {
// hg -> First git
// | \ |
// | Third <- Second
// | | /
// | | /
// +------> Last
//
HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
String[] hg_revs = { "h1", "h2" };
u.checkinInOrder(hg, hg_revs);
GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
String[] git_revs = { "g1", "g2" };
u.checkinInOrder(git, git_revs);
ScheduleTestUtil.AddedPipeline first = u.saveConfigWith("first", u.m(hg));
ScheduleTestUtil.AddedPipeline second = u.saveConfigWith("second", u.m(git));
ScheduleTestUtil.AddedPipeline third = u.saveConfigWith("third", u.m(first), u.m(second));
ScheduleTestUtil.AddedPipeline last = u.saveConfigWith("last", u.m(hg), u.m(second), u.m(third));
String first_1 = u.runAndPass(first, "h1");
String second_1 = u.runAndPass(second, "g1");
String second_2 = u.runAndPass(second, "g1");
String second_3 = u.runAndPass(second, "g2");
String second_4 = u.runAndPass(second, "g2");
String third_1 = u.runAndPass(third, first_1, second_2);
String third_2 = u.runAndPass(third, first_1, second_2);
String third_3 = u.runAndPass(third, first_1, second_2);
MaterialRevisions given = u.mrs(u.mr(hg, true, hg_revs), u.mr(second, true, second_4), u.mr(third, true, third_3));
MaterialRevisions expected = u.mrs(u.mr(hg, true, "h1"), u.mr(second, true, second_2), u.mr(third, true, third_3));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("last"));
assertThat(finalRevisions, is(expected));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldGetTheRevisionsFromTheNearestUpStreamPipeline.
@Test
public void shouldGetTheRevisionsFromTheNearestUpStreamPipeline() throws Exception {
HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
String[] hg_revs = { "hg1", "hg2", "hg3" };
int i = 1;
u.checkinInOrder(hg, u.d(i++), hg_revs);
ScheduleTestUtil.AddedPipeline up0 = u.saveConfigWith("up0", u.m(hg));
ScheduleTestUtil.AddedPipeline up1 = u.saveConfigWith("up1", u.m(up0), u.m(hg));
ScheduleTestUtil.AddedPipeline current = u.saveConfigWith("current", u.m(up1), u.m(hg));
String up0_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg1");
String up0_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg2");
String up0_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg3");
String up1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up1, u.d(i), up0_2, "hg2");
MaterialRevisions given = u.mrs(u.mr(hg, true, "hg3"), u.mr(up1, true, up1_1));
MaterialRevisions expected = u.mrs(u.mr(hg, true, "hg2"), u.mr(up1, true, up1_1));
MaterialRevisions revisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("current"));
assertThat(revisions, is(expected));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class PipelineMaterialRevisionTest method shouldNotSetFROMRevisionSameAsTORevisionWhenSCMMaterial.
@Test
public void shouldNotSetFROMRevisionSameAsTORevisionWhenSCMMaterial() {
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);
MaterialRevision revision = new MaterialRevision(material, latestModification, earlierModification);
PipelineMaterialRevision pmr = new PipelineMaterialRevision(9, revision, null);
assertThat(pmr.getToModification(), is(latestModification));
assertThat(pmr.getFromModification(), is(earlierModification));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class MixedMultipleMaterialsTest method shouldGetLatestModificationswithThreeRepositories.
@Test
public void shouldGetLatestModificationswithThreeRepositories() throws Exception {
HgMaterial hgMaterial = hgRepo.material();
SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
GitMaterial gitMaterial = gitRepo.createMaterial();
Materials materials = new Materials(hgMaterial, svnMaterial, gitMaterial);
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.getMaterialRevision(2).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(2).getRevision(), is(new Modifications(gitRepo.latestModifications()).latestRevision(gitMaterial)));
assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(3));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class PipelineLabelTest method shouldReplaceTheTemplateWithMultipleMaterialRevision.
@Test
public void shouldReplaceTheTemplateWithMultipleMaterialRevision() throws Exception {
PipelineLabel label = PipelineLabel.create("release-${svnMaterial}-${hg}");
MaterialRevisions materialRevisions = ModificationsMother.oneUserOneFile();
HgMaterial material = MaterialsMother.hgMaterial();
material.setName(new CaseInsensitiveString("hg"));
Modification modification = new Modification();
modification.setRevision("ae09876hj");
materialRevisions.addRevision(material, modification);
label.updateLabel(materialRevisions.getNamedRevisions());
assertThat(label.toString(), is("release-" + ModificationsMother.currentRevision() + "-ae09876hj"));
}
Aggregations