use of com.thoughtworks.go.domain.MaterialRevisions 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.domain.MaterialRevisions 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.domain.MaterialRevisions in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldResolveTriangleDependency.
/* TRIANGLE TEST BEGIN */
@Test
public void shouldResolveTriangleDependency() throws Exception {
GitMaterial git = new GitMaterial("git");
String[] git_revs = { "g1" };
u.checkinInOrder(git, git_revs);
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(git));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("p6", u.m(p4), u.m(p5));
String p4_1 = u.runAndPass(p4, "g1");
String p4_2 = u.runAndPass(p4, "g1");
String p5_1 = u.runAndPass(p5, p4_2);
String p4_3 = u.runAndPass(p4, "g1");
String p4_4 = u.runAndPass(p4, "g1");
PipelineConfigDependencyGraph graph = new PipelineConfigDependencyGraph(p6.config, new PipelineConfigDependencyGraph(p5.config), new PipelineConfigDependencyGraph(p4.config));
MaterialRevisions given = u.mrs(u.mr(p4, true, p4_4), u.mr(p5, true, p5_1));
MaterialRevisions expected = u.mrs(u.mr(p4, true, p4_2), u.mr(p5, true, p5_1));
assertThat(pipelineService.getRevisionsBasedOnDependencies(graph, given), is(expected));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class GitMultipleMaterialsTest method shouldFindModificationsForBothMaterials.
@Test
public void shouldFindModificationsForBothMaterials() throws Exception {
Materials materials = new Materials(repo.createMaterial("dest1"), repo.createMaterial("dest2"));
String fileName = "newFile.txt";
repo.addFileAndPush(fileName, "add a new file " + fileName);
MaterialRevisions materialRevisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
assertThat(materialRevisions.getRevisions().size(), is(2));
assertThat(materialRevisions, containsModifiedFile(fileName));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class SvnExternalTest method shouldGetLatestRevisionFromExpandedSvnExternalRepository.
@Test
public void shouldGetLatestRevisionFromExpandedSvnExternalRepository() {
MaterialRevisions materialRevisions = new MaterialRevisions();
Material svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
List<Modification> modifications = ((SvnMaterial) svnExt).latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
materialRevisions.addRevision(svnExt, modifications);
assertThat(materialRevisions.numberOfRevisions(), is(1));
MaterialRevision materialRevision = materialRevisions.getRevisions().get(0);
assertThat(materialRevision.getMaterial(), is(svnExt));
assertThat(materialRevision.getRevision().getRevision(), is("4"));
}
Aggregations