use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class AutoBuildCauseTest method shouldReturnPeggedRevisionsForUpstreamMaterialWhenFirstOrderDependencyMaterialIsChanged.
@Test
public void shouldReturnPeggedRevisionsForUpstreamMaterialWhenFirstOrderDependencyMaterialIsChanged() throws Exception {
HgMaterialConfig hg = MaterialConfigsMother.hgMaterialConfig();
PipelineConfig third = PipelineConfigMother.pipelineConfig("third", MaterialConfigsMother.dependencyMaterialConfig("second", "mingle"), new JobConfigs());
PipelineConfig second = PipelineConfigMother.pipelineConfig("second", MaterialConfigsMother.dependencyMaterialConfig("first", "mingle"), new JobConfigs());
PipelineConfig first = PipelineConfigMother.pipelineConfig("first", hg, new JobConfigs());
PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(third, new PipelineConfigDependencyGraph(second, new PipelineConfigDependencyGraph(first)), new PipelineConfigDependencyGraph(first));
MaterialRevisions revisions = new MaterialRevisions();
MaterialRevision firstRev = dependencyMaterialRevision("first", 10, "label", "mingle", 1, new Date());
firstRev.markAsNotChanged();
MaterialRevision secondRev = dependencyMaterialRevision("second", 1, "label", "mingle", 1, new Date());
secondRev.markAsChanged();
revisions.addRevision(secondRev);
revisions.addRevision(firstRev);
when(goConfigService.upstreamDependencyGraphOf("third", cruiseConfig)).thenReturn(dependencyGraph);
MaterialRevisions expectedRevisions = new MaterialRevisions();
when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenReturn(expectedRevisions);
assertThat(new AutoBuild(goConfigService, pipelineService, "third", new SystemEnvironment(), materialChecker, serverHealthService).onModifications(revisions, false, null).getMaterialRevisions(), sameInstance(expectedRevisions));
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class AutoBuildCauseTest method shouldReturnCorrectRevisionsIfFirstOrderMaterialIsChanged.
@Test
public void shouldReturnCorrectRevisionsIfFirstOrderMaterialIsChanged() throws Exception {
PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
String targetPipeline = dependencyGraph.getCurrent().name().toLower();
MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
MaterialRevisions firstOrderRevision = createSvnMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
MaterialRevision dependencyRevision = dependencyMaterialRevision("upstream", 1, "label", "first", 1, new Date());
revisions.addAll(firstOrderRevision);
revisions.addRevision(dependencyRevision);
dependencyRevision.markAsNotChanged();
firstOrderRevision.getMaterialRevision(0).markAsChanged();
revisions.getMaterialRevision(0).markAsChanged();
MaterialRevisions expectedRevisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("1"));
expectedRevisions.addRevision(dependencyRevision);
when(goConfigService.upstreamDependencyGraphOf(targetPipeline, cruiseConfig)).thenReturn(dependencyGraph);
when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenReturn(expectedRevisions);
assertThat(new AutoBuild(goConfigService, pipelineService, targetPipeline, new SystemEnvironment(), materialChecker, serverHealthService).onModifications(revisions, false, null).getMaterialRevisions(), is(expectedRevisions));
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class AutoBuildCauseTest method shouldUpdateRecomputedMaterialRevisionsChangedStatus.
@Test
public void shouldUpdateRecomputedMaterialRevisionsChangedStatus() throws Exception {
PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
String targetPipeline = dependencyGraph.getCurrent().name().toLower();
MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"), oneModifiedFile("1"));
MaterialRevisions revisionsForMaterial2 = multipleRevisions(MaterialsMother.svnMaterial(), 10, oneModifiedFile("svn2"));
MaterialRevision dependencyRevision = dependencyMaterialRevision("upstream", 1, "label", "first", 1, new Date());
revisions.addRevision(dependencyRevision);
revisions.addAll(revisionsForMaterial2);
for (MaterialRevision revision : revisions) {
revision.markAsChanged();
}
MaterialRevisions expectedRevisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("1"));
expectedRevisions.getMaterialRevision(0).markAsChanged();
MaterialRevisions expectedForMaterial2 = multipleRevisions(MaterialsMother.svnMaterial(), 10, oneModifiedFile("svn1"));
expectedForMaterial2.getMaterialRevision(0).markAsNotChanged();
expectedRevisions.addRevision(dependencyRevision);
expectedRevisions.addAll(expectedForMaterial2);
when(goConfigService.upstreamDependencyGraphOf(targetPipeline, cruiseConfig)).thenReturn(dependencyGraph);
when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenReturn(expectedRevisions);
BuildCause buildCause = new AutoBuild(goConfigService, pipelineService, targetPipeline, new SystemEnvironment(), materialChecker, serverHealthService).onModifications(revisions, false, null);
MaterialRevisions finalRevisions = buildCause.getMaterialRevisions();
assertThat(finalRevisions.numberOfRevisions(), is(expectedRevisions.numberOfRevisions()));
for (int i = 0; i < expectedRevisions.numberOfRevisions(); i++) {
MaterialRevision finalRev = finalRevisions.getMaterialRevision(i);
MaterialRevision expectedRev = expectedRevisions.getMaterialRevision(i);
assertThat(finalRev, is(expectedRev));
assertThat(finalRev.isChanged(), is(expectedRev.isChanged()));
}
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class DiskSpaceFullCheckerTest method tearDown.
@After
public void tearDown() throws Exception {
new SystemEnvironment().clearProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT);
verifyNoMoreInteractions(sender);
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class DiskSpaceFullCheckerTest method simulateFullDisk.
private CruiseConfig simulateFullDisk() {
new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, "1200009M");
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
return cruiseConfig;
}
Aggregations