use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class AdminRoleTest method shouldAddValidationErrorWithPipelineNameIfRoleNameInPipelinesAuthorizationDoesNotExist_PipelineConfigSaveValidationContext.
@Test
public void shouldAddValidationErrorWithPipelineNameIfRoleNameInPipelinesAuthorizationDoesNotExist_PipelineConfigSaveValidationContext() {
AdminRole role = new AdminRole(new CaseInsensitiveString("role2"));
PipelineConfig pipelineConfig = new PipelineConfig();
pipelineConfig.setName("foo");
PipelineConfigs pipelinesConfig = new BasicPipelineConfigs(new Authorization(new ViewConfig(role)), pipelineConfig);
CruiseConfig config = new BasicCruiseConfig(pipelinesConfig);
role.validate(PipelineConfigSaveValidationContext.forChain(true, "group", config, pipelineConfig));
ConfigErrors errors = role.errors();
assertThat(errors.isEmpty(), is(false));
assertThat(errors.on(AdminRole.NAME), is("Role \"role2\" does not exist."));
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class PipelineConfigValidationTest method shouldFailValidateWhenUpstreamStageForDependencyMaterialDoesNotExist.
@Test
void shouldFailValidateWhenUpstreamStageForDependencyMaterialDoesNotExist() {
String upstreamPipeline = "upstream";
String upstreamStage = "non-existant";
PipelineConfig upstream = GoConfigMother.createPipelineConfigWithMaterialConfig(upstreamPipeline, git("url"));
PipelineConfig pipelineConfig = GoConfigMother.createPipelineConfigWithMaterialConfig("downstream", new DependencyMaterialConfig(new CaseInsensitiveString(upstreamPipeline), new CaseInsensitiveString(upstreamStage)));
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(pipelineConfig, upstream));
boolean isValid = pipelineConfig.validateTree(PipelineConfigSaveValidationContext.forChain(true, cruiseConfig.getGroups().first().getGroup(), cruiseConfig, pipelineConfig));
assertThat(isValid).isFalse();
ConfigErrors materialErrors = pipelineConfig.materialConfigs().first().errors();
assertThat(materialErrors.isEmpty()).isFalse();
assertThat(materialErrors.firstError()).isEqualTo("Stage with name 'non-existant' does not exist on pipeline 'upstream', it is being referred to from pipeline 'downstream' (cruise-config.xml)");
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class PipelineConfigValidationTest method shouldFailValidateWhenUpstreamPipelineForDependencyMaterialDoesNotExist.
@Test
void shouldFailValidateWhenUpstreamPipelineForDependencyMaterialDoesNotExist() {
String upstreamPipeline = "non-existant";
PipelineConfig pipelineConfig = GoConfigMother.createPipelineConfigWithMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString(upstreamPipeline), new CaseInsensitiveString("non-existant")));
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(pipelineConfig));
boolean isValid = pipelineConfig.validateTree(PipelineConfigSaveValidationContext.forChain(true, cruiseConfig.getGroups().first().getGroup(), cruiseConfig, pipelineConfig));
assertThat(isValid).isFalse();
ConfigErrors materialErrors = pipelineConfig.materialConfigs().first().errors();
assertThat(materialErrors.isEmpty()).isFalse();
assertThat(materialErrors.firstError()).isEqualTo("Pipeline with name 'non-existant' does not exist, it is defined as a dependency for pipeline 'pipeline' (cruise-config.xml)");
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class MaterialConfigsTest method shouldNotAllowMultipleDependenciesForTheSamePipelines.
@Test
public void shouldNotAllowMultipleDependenciesForTheSamePipelines() throws Exception {
CruiseConfig config = GoConfigMother.configWithPipelines("pipeline1", "pipeline2", "pipeline3", "go");
DependencyMaterialConfig dependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage"));
DependencyMaterialConfig duplicateDependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage"));
MaterialConfigs materialConfigs = new MaterialConfigs(dependencyMaterial, duplicateDependencyMaterial);
ValidationContext validationContext = ConfigSaveValidationContext.forChain(config);
materialConfigs.validate(validationContext);
ConfigErrors errors = duplicateDependencyMaterial.errors();
assertThat(errors.isEmpty(), is(false));
assertThat(errors.on("pipelineStageName"), is("A pipeline can depend on each upstream pipeline only once. Remove one of the occurrences of 'pipeline2' from the current pipeline dependencies."));
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class TrackingToolTest method shouldEnsureTrackingToolLinkContainsIDForTheMatchingRegexGroup.
@Test
public void shouldEnsureTrackingToolLinkContainsIDForTheMatchingRegexGroup() {
TrackingTool trackingTool = new TrackingTool("http://no-id.com", "some-regex");
trackingTool.validate(null);
ConfigErrors configErrors = trackingTool.errors();
List<String> errors = configErrors.getAllOn(TrackingTool.LINK);
assertThat(errors.size(), is(1));
assertThat(errors, hasItem("Link must be a URL containing '${ID}'. Go will replace the string '${ID}' with the first matched group from the regex at run-time."));
}
Aggregations