use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class AdminRoleTest method shouldThrowExceptionIfRoleNameInStageAuthorizationDoesNotExist.
@Test
public void shouldThrowExceptionIfRoleNameInStageAuthorizationDoesNotExist() throws Exception {
AdminRole role = new AdminRole(new CaseInsensitiveString("role2"));
StageConfig stage = StageConfigMother.custom("ft", new AuthConfig(role));
CruiseConfig config = new BasicCruiseConfig(new BasicPipelineConfigs(new PipelineConfig(new CaseInsensitiveString("pipeline"), new MaterialConfigs(), stage)));
role.validate(ConfigSaveValidationContext.forChain(config));
ConfigErrors configErrors = role.errors();
assertThat(configErrors.isEmpty(), is(false));
assertThat(configErrors.on(AdminRole.NAME), is("Role \"role2\" does not exist."));
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class BuildTaskTest method shouldErrorOutIfWorkingDirectoryIsOutsideTheCurrentWorkingDirectoryForTemplates.
@Test
public void shouldErrorOutIfWorkingDirectoryIsOutsideTheCurrentWorkingDirectoryForTemplates() {
CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-blah");
BuildTask task = new AntTask();
task.setWorkingDirectory("/blah");
StageConfig stageConfig = StageConfigMother.manualStage("manualStage");
stageConfig.getJobs().get(0).addTask(task);
PipelineTemplateConfig template = new PipelineTemplateConfig(new CaseInsensitiveString("some-template"), stageConfig);
config.addTemplate(template);
List<ConfigErrors> errors = config.validateAfterPreprocess();
assertThat(errors.size(), is(1));
String message = "Task of job 'default' in stage 'manualStage' of template 'some-template' has path '/blah' which is outside the working directory.";
assertThat(task.errors().on(BuildTask.WORKING_DIRECTORY), is(message));
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class MergeCruiseConfigTest method shouldCollectOriginErrorsFromMaterialConfigs_InMergedConfig.
@Test
public void shouldCollectOriginErrorsFromMaterialConfigs_InMergedConfig() {
BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig(pipelines);
PartialConfig partialConfig = PartialConfigMother.withPipelineInGroup("pipe2", "g2");
partialConfig.getGroups().get(0).get(0).setOrigin(new RepoConfigOrigin());
cruiseConfig = new BasicCruiseConfig(mainCruiseConfig, partialConfig);
PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
PipelineConfig pipeline2 = PipelineConfigMother.createPipelineConfigWithStage("pipeline2", "stage");
pipeline2.setOrigin(new RepoConfigOrigin());
partialConfig.getGroups().addPipeline("g2", pipeline2);
goConfigMother.setDependencyOn(cruiseConfig, pipeline1, "pipeline2", "stage");
List<ConfigErrors> allErrors = cruiseConfig.validateAfterPreprocess();
assertThat(allErrors.size(), is(1));
assertNotNull(allErrors.get(0).on("origin"));
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class MergeCruiseConfigTest method shouldCollectPipelineNameConflictErrorsInTheChildren_InMergedConfig_WhenCloned.
@Test
public void shouldCollectPipelineNameConflictErrorsInTheChildren_InMergedConfig_WhenCloned() {
//we need this case because cloning has proven to be problematic with complex object graph in merged config
BasicCruiseConfig mainCruiseConfig = GoConfigMother.configWithPipelines("pipeline-1");
PartialConfig partialConfig = PartialConfigMother.withPipelineInGroup("pipeline-1", "g2");
partialConfig.setOrigin(new RepoConfigOrigin());
CruiseConfig config = new BasicCruiseConfig(mainCruiseConfig, partialConfig);
Cloner CLONER = new Cloner();
CruiseConfig cloned = CLONER.deepClone(config);
List<ConfigErrors> allErrors = cloned.validateAfterPreprocess();
assertThat(allErrors.size(), is(2));
assertThat(allErrors.get(0).on("name"), is("You have defined multiple pipelines named 'pipeline-1'. Pipeline names must be unique. Source(s): [http://some.git at 1234fed, cruise-config.xml]"));
assertThat(allErrors.get(1).on("name"), is("You have defined multiple pipelines named 'pipeline-1'. Pipeline names must be unique. Source(s): [http://some.git at 1234fed, cruise-config.xml]"));
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class GoConfigParallelGraphWalkerTest method shouldAddErrorsToRawCruiseConfigWhenTemplateHasErrors.
@Test
public void shouldAddErrorsToRawCruiseConfigWhenTemplateHasErrors() {
CruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("pipeline-1");
cruiseConfig.getTemplates().add(new PipelineTemplateConfig(new CaseInsensitiveString("invalid template name"), new StageConfig(new CaseInsensitiveString("stage-1"), new JobConfigs(new JobConfig("job-1")))));
PipelineConfig pipelineWithTemplate = new PipelineConfig(new CaseInsensitiveString("pipeline-with-template"), MaterialConfigsMother.defaultMaterialConfigs());
pipelineWithTemplate.setTemplateName(new CaseInsensitiveString("invalid template name"));
cruiseConfig.getGroups().get(0).add(pipelineWithTemplate);
CruiseConfig rawCruiseConfig = new Cloner().deepClone(cruiseConfig);
MagicalGoConfigXmlLoader.validate(cruiseConfig);
cruiseConfig.copyErrorsTo(rawCruiseConfig);
ConfigErrors templateErrors = rawCruiseConfig.getTemplateByName(new CaseInsensitiveString("invalid template name")).errors();
assertThat(templateErrors.getAll().size(), is(1));
assertThat(templateErrors.getAll().get(0), is("Invalid template name 'invalid template name'. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
}
Aggregations