use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRPipelineTest method shouldAddAnErrorWhenBothTemplateAndStagesAreDefined.
@Test
public void shouldAddAnErrorWhenBothTemplateAndStagesAreDefined() throws Exception {
CRPipeline crPipeline = new CRPipeline("p1", "g1", veryCustomGit, "template", buildStage);
ErrorCollection errorCollection = new ErrorCollection();
crPipeline.getErrors(errorCollection, "TEST");
assertThat(errorCollection.getErrorCount(), is(1));
assertThat(errorCollection.getErrorsAsText(), contains("Pipeline has to either define stages or template. Not both."));
}
use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRPipelineTest method shouldAddAnErrorForDuplicateParameterNames.
@Test
public void shouldAddAnErrorForDuplicateParameterNames() throws Exception {
ArrayList<CRMaterial> materials = new ArrayList<>();
materials.add(veryCustomGit);
ArrayList<CRParameter> crParameters = new ArrayList<>();
crParameters.add(new CRParameter("param1", "value1"));
crParameters.add(new CRParameter("param1", "value2"));
CRPipeline crPipeline = new CRPipeline("p1", "g1", "label", LOCK_VALUE_LOCK_ON_FAILURE, null, null, null, new ArrayList<>(), materials, null, "t1", crParameters);
ErrorCollection errors = new ErrorCollection();
crPipeline.getErrors(errors, "TEST");
assertThat(errors.getErrorsAsText(), contains("Param name 'param1' is not unique."));
}
use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRPipelineTest method shouldAddAnErrorForDuplicateEnvironmentVariables.
@Test
public void shouldAddAnErrorForDuplicateEnvironmentVariables() throws Exception {
ArrayList<CRMaterial> materials = new ArrayList<>();
materials.add(veryCustomGit);
ArrayList<CREnvironmentVariable> crEnvironmentVariables = new ArrayList<>();
crEnvironmentVariables.add(new CREnvironmentVariable("env1", "value1"));
crEnvironmentVariables.add(new CREnvironmentVariable("env1", "value2"));
CRPipeline crPipeline = new CRPipeline("p1", "g1", "label", LOCK_VALUE_LOCK_ON_FAILURE, null, null, null, crEnvironmentVariables, materials, null, "t1", new ArrayList<>());
ErrorCollection errors = new ErrorCollection();
crPipeline.getErrors(errors, "TEST");
assertThat(errors.getErrorsAsText(), contains("Environment variable env1 defined more than once"));
}
use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRPipelineTest method shouldAddAnErrorIfLockBehaviorValueIsInvalid.
@Test
public void shouldAddAnErrorIfLockBehaviorValueIsInvalid() throws Exception {
CRPipeline validPipelineWithInvalidLockBehaviorOnly = new CRPipeline("pipe1", "group1", null, "INVALID_LOCK_VALUE", null, null, null, emptyList(), asList(veryCustomGit), asList(buildStage), null, emptyList());
ErrorCollection errorCollection = new ErrorCollection();
validPipelineWithInvalidLockBehaviorOnly.getErrors(errorCollection, "TEST");
String expectedMessage = "Lock behavior has an invalid value (INVALID_LOCK_VALUE). Valid values are:";
assertThat(errorCollection.getErrorCount(), is(1));
assertThat(errorCollection.getOrCreateErrorList(validPipelineWithInvalidLockBehaviorOnly.getLocation("TEST")).get(0), contains(expectedMessage));
}
use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRStageTest method shouldCheckErrorsInJobs.
@Test
public void shouldCheckErrorsInJobs() {
CRStage withNamelessJob = new CRStage("build", new CRJob());
ErrorCollection errors = new ErrorCollection();
withNamelessJob.getErrors(errors, "TEST");
String fullError = errors.getErrorsAsText();
assertThat(fullError, contains("TEST; Stage (build)"));
assertThat(fullError, contains("Missing field 'name'"));
}
Aggregations