use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineConfigSaveValidationContextTest method shouldGetDependencyMaterialsForPipelines.
@Test
public void shouldGetDependencyMaterialsForPipelines() {
BasicCruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("p1", "p2", "p3");
PipelineConfig p2 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p2"));
p2.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p1"), new CaseInsensitiveString("stage")));
PipelineConfig p3 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p3"));
p3.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p2"), new CaseInsensitiveString("stage")));
PipelineConfigSaveValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig);
assertThat(context.getDependencyMaterialsFor(new CaseInsensitiveString("p1")).getDependencies().isEmpty(), is(true));
assertThat(context.getDependencyMaterialsFor(new CaseInsensitiveString("p2")).getDependencies(), contains(new Node.DependencyNode(new CaseInsensitiveString("p1"), new CaseInsensitiveString("stage"))));
assertThat(context.getDependencyMaterialsFor(new CaseInsensitiveString("p3")).getDependencies(), contains(new Node.DependencyNode(new CaseInsensitiveString("p2"), new CaseInsensitiveString("stage"))));
assertThat(context.getDependencyMaterialsFor(new CaseInsensitiveString("junk")).getDependencies().isEmpty(), is(true));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineTemplateConfigTest method shouldValidateTemplateJobsUsedInDownstreamPipelines.
@Test
public void shouldValidateTemplateJobsUsedInDownstreamPipelines() {
JobConfig jobConfigWithExecTask = new JobConfig(new CaseInsensitiveString("defaultJob"));
jobConfigWithExecTask.addTask(new ExecTask("ls", "l", "server/config"));
JobConfigs jobConfigs = new JobConfigs(jobConfigWithExecTask);
JobConfig jobConfigWithFetchTask = new JobConfig(new CaseInsensitiveString("fetchJob"));
jobConfigWithFetchTask.addTask(new FetchTask(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"), new CaseInsensitiveString("non-existent-job"), "src", "dest"));
JobConfigs jobConfigsForDownstream = new JobConfigs(jobConfigWithFetchTask);
StageConfig stageConfig = StageConfigMother.custom("stage", jobConfigs);
PipelineTemplateConfig template = PipelineTemplateConfigMother.createTemplate("template", stageConfig);
PipelineConfig upstreamPipelineUsingTemplate = PipelineConfigMother.pipelineConfigWithTemplate("pipeline", "template");
upstreamPipelineUsingTemplate.usingTemplate(template);
// Pipeline and stage of upstreamPipelineUsingTemplate
MaterialConfig dependency = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"));
PipelineConfig downStreamPipeline = PipelineConfigMother.pipelineConfig("downstreamPipeline", new MaterialConfigs(dependency), jobConfigsForDownstream);
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
cruiseConfig.addTemplate(template);
cruiseConfig.addPipelineWithoutValidation("group", upstreamPipelineUsingTemplate);
cruiseConfig.addPipelineWithoutValidation("group", downStreamPipeline);
template.validateTree(ConfigSaveValidationContext.forChain(cruiseConfig), cruiseConfig, false);
assertThat(template.errors().getAllOn("base"), is(Arrays.asList("\"downstreamPipeline :: mingle :: fetchJob\" tries to fetch artifact from job \"pipeline :: stage :: non-existent-job\" which does not exist.")));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineTemplateConfigTest method shouldValidateTemplateStageUsedInDownstreamPipelines.
@Test
public void shouldValidateTemplateStageUsedInDownstreamPipelines() {
JobConfig jobConfigWithExecTask = new JobConfig(new CaseInsensitiveString("defaultJob"));
jobConfigWithExecTask.addTask(new ExecTask("ls", "l", "server/config"));
JobConfigs jobConfigs = new JobConfigs(jobConfigWithExecTask);
StageConfig stageConfig = StageConfigMother.custom("stage", jobConfigs);
PipelineTemplateConfig template = PipelineTemplateConfigMother.createTemplate("template", stageConfig);
PipelineConfig upstreamPipelineUsingTemplate = PipelineConfigMother.pipelineConfigWithTemplate("pipeline", "template");
upstreamPipelineUsingTemplate.usingTemplate(template);
// Pipeline and stage of upstreamPipelineUsingTemplate
MaterialConfig dependency = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("non-existent-stage"));
PipelineConfig downStreamPipeline = PipelineConfigMother.pipelineConfig("downstreamPipeline", new MaterialConfigs(dependency));
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
cruiseConfig.addTemplate(template);
cruiseConfig.addPipelineWithoutValidation("group", upstreamPipelineUsingTemplate);
cruiseConfig.addPipelineWithoutValidation("group", downStreamPipeline);
template.validateTree(ConfigSaveValidationContext.forChain(cruiseConfig), cruiseConfig, false);
assertThat(template.errors().getAllOn("base"), is(Arrays.asList("Stage with name 'non-existent-stage' does not exist on pipeline 'pipeline', it is being referred to from pipeline 'downstreamPipeline' (cruise-config.xml)")));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldAllowToDependOnPipelineDefinedInConfigRepository_WhenInConfigRepository.
@Test
public void shouldAllowToDependOnPipelineDefinedInConfigRepository_WhenInConfigRepository() throws Exception {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
pipeline1.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(new SvnMaterialConfig("http://mysvn", false), "myplugin"), "123"));
pipeline2.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(new SvnMaterialConfig("http://othersvn", false), "myplugin"), "2222"));
pipeline1.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(true));
pipeline2.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline2));
DependencyMaterialConfig dep = pipeline2.materialConfigs().findDependencyMaterial(new CaseInsensitiveString("pipeline1"));
assertThat(dep.errors().isEmpty(), is(true));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldAllowToDependOnPipelineDefinedInFile_WhenInFile.
@Test
public void shouldAllowToDependOnPipelineDefinedInFile_WhenInFile() throws Exception {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
pipeline1.setOrigin(new FileConfigOrigin());
pipeline2.setOrigin(new FileConfigOrigin());
pipeline1.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(true));
pipeline2.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline2));
DependencyMaterialConfig dep = pipeline2.materialConfigs().findDependencyMaterial(new CaseInsensitiveString("pipeline1"));
assertThat(dep.errors().isEmpty(), is(true));
}
Aggregations