use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt.
@Test
public void hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt() {
HgMaterial hgMaterial = MaterialsMother.hgMaterial("hgUrl", "dest");
MaterialRevision materialRevision = saveOneScmModification(hgMaterial, "user", "file");
PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial.config()), "dev");
MaterialRevisions materialRevisions = new MaterialRevisions(materialRevision);
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
pipelineSqlMapDao.save(pipeline);
MaterialRevision notBuiltRevision = saveOneScmModification(hgMaterial, "user", "file2");
MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(hgMaterial, notBuiltRevision.getLatestModification()));
assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(false));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class PipelineServiceIntegrationTest method shouldReturnCorrectNumberOfMaterialRevisionsAndMaterials.
@Test
public void shouldReturnCorrectNumberOfMaterialRevisionsAndMaterials() throws Exception {
File file1 = new File("file1");
File file2 = new File("file2");
File file3 = new File("file3");
File file4 = new File("file4");
Material hg = new HgMaterial("url", "Dest");
String[] hgRevs = new String[] { "h1" };
u.checkinFiles(hg, "h1", a(file1, file2, file3, file4), ModifiedAction.added);
ScheduleTestUtil.AddedPipeline pair01 = u.saveConfigWith("pair01", "stageName", u.m(hg));
u.runAndPass(pair01, hgRevs);
ReflectionUtil.invoke(pipelineSqlMapDao, "initDao");
Pipeline pipeline = pipelineService.mostRecentFullPipelineByName("pair01");
MaterialRevisions materialRevisions = pipeline.getBuildCause().getMaterialRevisions();
assertThat(materialRevisions.getMaterials().size(), is(1));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldChooseTheAppropriateRevisionsOfAllMaterials_inAComplexMultipleDiamondDependencySituation_withDependencyMaterialsNotResolvingStrictly.
@Test
public void shouldChooseTheAppropriateRevisionsOfAllMaterials_inAComplexMultipleDiamondDependencySituation_withDependencyMaterialsNotResolvingStrictly() throws Exception {
/**
* +-----------------------------+
* | hg---------->P4 |
* | |\ | |
* | | \ | |
* | | \----\ | |
* | V \ | |
* | /----> P3 ------\\ | |
* | / \\ | |
* | / \V| |
* |/ V V |
* svn -----> P1 ---------> P6 <-+---+
* \ | ^ ^ |
* \ | / | |
* \ V / | |
* \---> P2-------/ | |
* # ^ | |
* | | |
* git----------->P5<-----git2
*/
int i = 1;
SvnMaterial svn = u.wf(new SvnMaterial("svn", "username", "password", false), "folder1");
String[] svn_revs = { "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10" };
u.checkinInOrder(svn, u.d(i++), svn_revs);
HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder2");
String[] hg_revs = { "h1", "h2", "h3", "h4", "h5", "h6", "h7" };
u.checkinInOrder(hg, u.d(i++), hg_revs);
GitMaterial git1 = u.wf(new GitMaterial("git-1"), "folder3");
u.checkinInOrder(git1, u.d(i++), "g1-1", "g1-2", "g1-3", "g1-4", "g1-5", "g1-6");
GitMaterial git2 = u.wf(new GitMaterial("git-2"), "folder4");
String[] git2_revs = { "g2-1", "g2-2", "g2-3", "g2-4", "g2-5", "g2-6", "g2-7", "g2-8" };
u.checkinInOrder(git2, u.d(i++), git2_revs);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(svn));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(p1), u.m(svn), u.m(git1));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(svn), u.m(hg));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(hg));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("P5", u.m(git1), u.m(git2));
ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("P6", u.m(svn), u.m(p4), u.m(hg), u.m(p3), u.m(p1), u.m(p2), u.m(p5), u.m(git2));
CruiseConfig cruiseConfig = goConfigDao.load();
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s1");
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s2");
String p1_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s3");
String p1_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s4");
String p1_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s6");
String p1_6 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s8");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1, "s1", "g1-2");
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2, "s2", "g1-3");
String p2_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_4, "s5", "g1-5");
String p2_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_5, "s6", "g1-6");
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "s1", "h1");
String p3_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "s2", "h3");
String p3_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "s3", "h5");
String p3_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "s7", "h6");
String p4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "h1");
String p4_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "h3");
String p4_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "h6");
String p4_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "h7");
String p5_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), "g1-2", "g2-2");
String p5_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), "g1-3", "g2-3");
String p5_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), "g1-6", "g2-5");
MaterialRevisions given = u.mrs(u.mr(rel(git2, p6), true, git2_revs), u.mr(rel(p5, p6), false, p5_3), u.mr(rel(p2, p6), false, p2_4), u.mr(rel(p1, p6), true, p1_6), u.mr(rel(p3, p6), false, p3_4), u.mr(rel(hg, p6), false, hg_revs), u.mr(rel(p4, p6), false, p4_4), u.mr(rel(svn, p6), true, svn_revs));
MaterialRevisions expected = u.mrs(u.mr(rel(git2, p6), true, "g2-3"), u.mr(rel(p5, p6), false, p5_2), u.mr(rel(p2, p6), false, p2_2), u.mr(rel(p1, p6), false, p1_2), u.mr(rel(p3, p6), false, p3_2), u.mr(rel(hg, p6), false, "h3"), u.mr(rel(p4, p6), false, p4_2), u.mr(rel(svn, p6), true, "s2"));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p6, cruiseConfig, given);
assertThat(finalRevisions, is(expected));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldGetTheRevisionsFromTheUpStreamPipelineThatUsesTheSameMaterialEvenIfItIsNotADirectMaterial.
@Test
public void shouldGetTheRevisionsFromTheUpStreamPipelineThatUsesTheSameMaterialEvenIfItIsNotADirectMaterial() throws Exception {
HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
String[] hg_revs = { "hg1", "hg2", "hg3" };
u.checkinInOrder(hg, hg_revs);
ScheduleTestUtil.AddedPipeline up0 = u.saveConfigWith("up0", u.m(hg));
ScheduleTestUtil.AddedPipeline up1 = u.saveConfigWith("up1", u.m(up0));
ScheduleTestUtil.AddedPipeline current = u.saveConfigWith("current", u.m(up1), u.m(hg));
String up0_1 = u.runAndPass(up0, "hg1");
String up0_2 = u.runAndPass(up0, "hg1");
String up1_1 = u.runAndPass(up1, up0_2);
MaterialRevisions given = u.mrs(u.mr(hg, false, "hg3"), u.mr(up1, true, up1_1));
MaterialRevisions expected = u.mrs(u.mr(hg, false, "hg1"), u.mr(up1, true, up1_1));
assertThat(getRevisionsBasedOnDependencies(current, goConfigDao.load(), given), is(expected));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldIgnoreUpstreamPipelineWhenThereIsNothingInCommon.
@Test
public void shouldIgnoreUpstreamPipelineWhenThereIsNothingInCommon() throws Exception {
SvnMaterial svn = u.wf(new SvnMaterial("url", "username", "password", false), "folder1");
String[] svn_revs = { "s1", "s2" };
int i = 1;
u.checkinInOrder(svn, u.d(i++), svn_revs);
HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder2");
String[] hg_revs = { "hg1", "hg2", "hg3" };
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));
ScheduleTestUtil.AddedPipeline current = u.saveConfigWith("current", u.m(up0), u.m(up1), u.m(svn));
String up0_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg1", "hg2", "hg3");
String up0_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg1", "hg2", "hg3");
String up1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up1, u.d(i++), up0_1);
MaterialRevisions given = u.mrs(u.mr(up0, true, up0_2), u.mr(up1, false, up1_1), u.mr(svn, true, "s1", "s2"));
MaterialRevisions expected = u.mrs(u.mr(up0, true, up0_2), u.mr(up1, false, up1_1), u.mr(svn, true, "s2"));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("current"));
assertThat(finalRevisions, is(expected));
}
Aggregations