use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class TimedBuildTest method shouldReturnEmptyBuildCauseIfThereIsNoModification_whenTriggeringOnlyForMaterialChange.
@Test
public void shouldReturnEmptyBuildCauseIfThereIsNoModification_whenTriggeringOnlyForMaterialChange() throws Exception {
MaterialRevisions someRevisions = new MaterialRevisions(new MaterialRevision(MaterialsMother.gitMaterial("git://url"), ModificationsMother.aCheckIn("1", "file1.txt")));
BuildType timedBuild = new TimedBuild();
PipelineConfig timerConfig = PipelineConfigMother.pipelineConfigWithTimer("Timer", "* * * * * ?", true);
BuildCause buildCause = timedBuild.onEmptyModifications(timerConfig, someRevisions);
assertThat(buildCause, is(nullValue()));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldResolveDependenciesAcrossSeveralLevelsOfLinearRelations.
@Test
public void shouldResolveDependenciesAcrossSeveralLevelsOfLinearRelations() {
GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
String[] git_revs = { "g1", "g2" };
u.checkinInOrder(git, git_revs);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(git));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(p1));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(p2));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p3));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("P5", u.m(git), u.m(p4));
CruiseConfig cruiseConfig = goConfigDao.load();
String p1_1 = u.runAndPass(p1, "g1");
String p2_1 = u.runAndPass(p2, p1_1);
String p3_1 = u.runAndPass(p3, p2_1);
String p4_1 = u.runAndPass(p4, p3_1);
String p1_2 = u.runAndPass(p1, "g2");
String p2_2 = u.runAndPass(p2, p1_2);
MaterialRevisions given = u.mrs(u.mr(git, true, git_revs), u.mr(p4, true, p4_1));
MaterialRevisions expected = u.mrs(u.mr(git, true, "g1"), u.mr(p4, true, p4_1));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("p5"));
assertThat(finalRevisions, is(expected));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldResolveSimpleDiamondAndThrowLimitException.
@Test
@ExpectedException(MaxBackTrackLimitReachedException.class)
public void shouldResolveSimpleDiamondAndThrowLimitException() {
int i = 1;
GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder");
String[] git_revs1 = { "g11", "g12" };
u.checkinInOrder(git1, u.d(i++), git_revs1);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git1));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p1));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
CruiseConfig cruiseConfig = goConfigDao.load();
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), p1_1);
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g12");
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2);
MaterialRevisions given = u.mrs(u.mr(p2, true, p2_2), u.mr(p3, false, p3_1));
MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_1), u.mr(p3, false, p3_1));
assertThat(getRevisionsBasedOnDependencies(p4, cruiseConfig, given), is(expected));
systemEnvironment.set(SystemEnvironment.RESOLVE_FANIN_MAX_BACK_TRACK_LIMIT, 1);
getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldResolveSimpleDiamondWithMultipleScmRevisionsThatHasTriggeredTheUpstreamPipeline.
@Test
public void shouldResolveSimpleDiamondWithMultipleScmRevisionsThatHasTriggeredTheUpstreamPipeline() {
int i = 1;
GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder");
String[] git_revs1 = { "g11", "g12", "g13" };
u.checkinInOrder(git1, u.d(i++), git_revs1);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git1));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p2), u.m(git1));
CruiseConfig cruiseConfig = goConfigDao.load();
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), p2_1, "g11");
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionObjects(p1, u.d(i++), u.rs("g12", "g13"));
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2);
MaterialRevisions given = u.mrs(u.mr(p2, true, p2_2), u.mr(git1, true, "g12", "g13"));
MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_2), u.mr(git1, true, "g12", "g13"));
assertThat(getRevisionsBasedOnDependencies(p3, cruiseConfig, given), is(expected));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class AutoBuildIntegrationTest method shouldCreateBuildCauseOnMaterialConfigChange.
@Test
public void shouldCreateBuildCauseOnMaterialConfigChange() throws Exception {
//down_pipe <- svn
// ^ /
// | / => down_pipe <- up_pipe <- svn
// up_pipe
//
SvnMaterial svn = scheduleUtil.wf(new SvnMaterial("svn", "username", "password", false), "folder1");
String[] svn_revs = { "s1" };
scheduleUtil.checkinInOrder(svn, svn_revs);
ScheduleTestUtil.AddedPipeline up_pipe = scheduleUtil.saveConfigWith("up_pipe", scheduleUtil.m(svn));
ScheduleTestUtil.AddedPipeline down_pipe = scheduleUtil.saveConfigWith("down_pipe", scheduleUtil.m(svn), scheduleUtil.m(up_pipe));
String up_pipe_1 = scheduleUtil.runAndPass(up_pipe, "s1");
pipelineTimeline.update();
String down_pipe_1 = scheduleUtil.runAndPass(down_pipe, "s1", up_pipe_1);
pipelineTimeline.update();
down_pipe.config.removeMaterialConfig(svn.config());
CruiseConfig currentConfig = goConfigService.getCurrentConfig();
currentConfig.pipelineConfigByName(new CaseInsensitiveString("down_pipe")).removeMaterialConfig(svn.config());
configHelper.writeConfigFile(currentConfig);
goConfigDao.load();
MaterialRevisions given = scheduleUtil.mrs(scheduleUtil.mr(up_pipe, true, up_pipe_1));
MaterialRevisions expected = scheduleUtil.mrs(scheduleUtil.mr(up_pipe, true, up_pipe_1));
AutoBuild autoBuildType = new AutoBuild(goConfigService, pipelineService, "down_pipe", systemEnvironment, materialChecker, serverHealthService);
assertThat(autoBuildType.onModifications(given, true, null).getMaterialRevisions(), is(expected));
}
Aggregations