use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineConfigTest method shouldValidateCorrectPipelineLabelWithoutAnyMaterial.
@Test
public void shouldValidateCorrectPipelineLabelWithoutAnyMaterial() {
PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("cruise"), new MaterialConfigs(), new StageConfig(new CaseInsensitiveString("first"), new JobConfigs()));
pipelineConfig.setLabelTemplate("pipeline-${COUNT}-alpha");
pipelineConfig.validate(null);
assertThat(pipelineConfig.errors().isEmpty(), is(true));
assertThat(pipelineConfig.errors().on(PipelineConfig.LABEL_TEMPLATE), is(nullValue()));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineConfigTest method shouldThrowExceptionForEmptyPipeline.
@Test
public void shouldThrowExceptionForEmptyPipeline() {
PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("cruise"), new MaterialConfigs());
try {
pipelineConfig.isFirstStageManualApproval();
fail("Should throw exception if pipeline has no pipeline");
} catch (IllegalStateException e) {
assertThat(e.getMessage(), containsString("Pipeline [" + pipelineConfig.name() + "] doesn't have any stage"));
}
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineConfigValidationTest method shouldValidateThatPipelineAssociatedToATemplateDoesNotHaveStagesDefinedLocally.
@Test
public void shouldValidateThatPipelineAssociatedToATemplateDoesNotHaveStagesDefinedLocally() {
PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("wunderbar"), new MaterialConfigs());
config.addPipeline("g", pipelineConfig);
pipelineConfig.setTemplateName(new CaseInsensitiveString("template-name"));
pipelineConfig.addStageWithoutValidityAssertion(new StageConfig(new CaseInsensitiveString("stage"), new JobConfigs()));
pipelineConfig.validateTemplate(null);
assertThat(pipelineConfig.errors().on("stages"), is("Cannot add stages to pipeline 'wunderbar' which already references template 'template-name'"));
assertThat(pipelineConfig.errors().on("template"), is("Cannot set template 'template-name' on pipeline 'wunderbar' because it already has stages defined"));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineConfigValidationTest method shouldFailValidationIfAJobIsDeletedWhileItsStillReferredToByADescendentPipelineThroughFetchArtifact.
@Test
public void shouldFailValidationIfAJobIsDeletedWhileItsStillReferredToByADescendentPipelineThroughFetchArtifact() {
BasicCruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("p1", "p2", "p3");
PipelineConfig p1 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p1"));
PipelineConfig p2 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p2"));
PipelineConfig p3 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p3"));
p2.addMaterialConfig(new DependencyMaterialConfig(p1.name(), p1.first().name()));
JobConfig p2S2J2 = new JobConfig(new CaseInsensitiveString("j2"));
p2S2J2.addTask(fetchTaskFromSamePipeline(p2));
p2.add(new StageConfig(new CaseInsensitiveString("stage2"), new JobConfigs(p2S2J2)));
p3.addMaterialConfig(new DependencyMaterialConfig(p2.name(), p2.first().name()));
p3.first().getJobs().first().addTask(new FetchTask(new CaseInsensitiveString("p1/p2"), p1.first().name(), p1.first().getJobs().first().name(), "src", "dest"));
StageConfig stageConfig = new StageConfig(new CaseInsensitiveString("stage"), new JobConfigs(new JobConfig(new CaseInsensitiveString("new-job"))));
PipelineConfig pipelineConfig = new PipelineConfig(p1.name(), new MaterialConfigs(), stageConfig);
String group = cruiseConfig.getGroups().first().getGroup();
cruiseConfig.update(group, pipelineConfig.name().toString(), pipelineConfig);
PipelineConfigSaveValidationContext validationContext = PipelineConfigSaveValidationContext.forChain(false, group, cruiseConfig, pipelineConfig);
pipelineConfig.validateTree(validationContext);
assertThat(pipelineConfig.errors().on("base"), is("\"p3 :: stage :: job\" tries to fetch artifact from job \"p1 :: stage :: job\" which does not exist."));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineConfigValidationTest method shouldValidateAndUpdatePipelineConfig.
@Test
public void shouldValidateAndUpdatePipelineConfig() {
PipelineConfig pipeline = new PipelineConfig();
pipeline.setName("validPipeline");
pipeline.setMaterialConfigs(new MaterialConfigs(MaterialConfigsMother.gitMaterialConfig(), MaterialConfigsMother.svnMaterialConfig()));
StageConfig stage1 = getStageConfig("stage1", "s1j1");
StageConfig stage2 = getStageConfig("stage2", "s2j1");
pipeline.getStages().add(stage1);
pipeline.getStages().add(stage2);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs("group", new Authorization(), pipeline));
boolean isValid = pipeline.validateTree(PipelineConfigSaveValidationContext.forChain(true, cruiseConfig.getGroups().first().getGroup(), cruiseConfig, pipeline));
assertThat(isValid, is(true));
assertThat(pipeline.materialConfigs().errors().isEmpty(), is(true));
assertThat(pipeline.materialConfigs().get(0).errors().isEmpty(), is(true));
assertThat(pipeline.materialConfigs().get(1).errors().isEmpty(), is(true));
assertThat(pipeline.errors().getAll().isEmpty(), is(true));
}
Aggregations