Search in sources :

Example 36 with ConfigErrors

use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.

the class ParamConfigTest method validate_shouldMakeSureParamNameIsOfNameType.

@Test
public void validate_shouldMakeSureParamNameIsOfNameType() {
    assertThat(createAndValidate("name").errors().isEmpty(), is(true));
    ConfigErrors errors = createAndValidate(".name").errors();
    assertThat(errors.isEmpty(), is(false));
    assertThat(errors.on(ParamConfig.NAME), is("Invalid parameter name '.name'. This must be alphanumeric and can contain underscores, hyphens and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
}
Also used : ConfigErrors(com.thoughtworks.go.domain.ConfigErrors) Test(org.junit.jupiter.api.Test)

Example 37 with ConfigErrors

use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.

the class JobConfigTest method shouldValidateAgainstSettingRunOnAllAgentsAndRunInstanceCountSetTogether.

@Test
void shouldValidateAgainstSettingRunOnAllAgentsAndRunInstanceCountSetTogether() {
    JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test"));
    jobConfig.setRunOnAllAgents(true);
    jobConfig.setRunInstanceCount(10);
    jobConfig.validate(ConfigSaveValidationContext.forChain(new BasicCruiseConfig()));
    ConfigErrors configErrors = jobConfig.errors();
    assertThat(configErrors.isEmpty()).isFalse();
    assertThat(configErrors.on(JobConfig.RUN_TYPE)).isEqualTo("Job cannot be 'run on all agents' type and 'run multiple instance' type together.");
}
Also used : ConfigErrors(com.thoughtworks.go.domain.ConfigErrors) Test(org.junit.jupiter.api.Test)

Example 38 with ConfigErrors

use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.

the class JobConfigTest method shouldValidateTheJobNameAgainstHaving_runInstance.

@Test
void shouldValidateTheJobNameAgainstHaving_runInstance() {
    String jobName = "a-runInstance-1";
    ConfigErrors configErrors = createJobAndValidate(jobName).errors();
    assertThat(configErrors.isEmpty()).isFalse();
    assertThat(configErrors.on(JobConfig.NAME)).isEqualTo(String.format("A job cannot have 'runInstance' in it's name: %s because it is a reserved keyword", jobName));
}
Also used : ConfigErrors(com.thoughtworks.go.domain.ConfigErrors) Test(org.junit.jupiter.api.Test)

Example 39 with ConfigErrors

use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.

the class JobConfigTest method shouldValidateTheJobNameAgainstHaving_runOnAll.

@Test
void shouldValidateTheJobNameAgainstHaving_runOnAll() {
    String jobName = "a-runOnAll-1";
    ConfigErrors configErrors = createJobAndValidate(jobName).errors();
    assertThat(configErrors.isEmpty()).isFalse();
    assertThat(configErrors.on(JobConfig.NAME)).isEqualTo(String.format("A job cannot have 'runOnAll' in it's name: %s because it is a reserved keyword", jobName));
}
Also used : ConfigErrors(com.thoughtworks.go.domain.ConfigErrors) Test(org.junit.jupiter.api.Test)

Example 40 with ConfigErrors

use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.

the class JobConfigTest method shouldValidateAgainstSettingRunOnAllAgentsForAJobAssignedToElasticAgent.

@Test
void shouldValidateAgainstSettingRunOnAllAgentsForAJobAssignedToElasticAgent() {
    JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test"));
    jobConfig.setRunOnAllAgents(true);
    jobConfig.setElasticProfileId("ubuntu-dev");
    jobConfig.validate(ConfigSaveValidationContext.forChain(new BasicCruiseConfig()));
    ConfigErrors configErrors = jobConfig.errors();
    assertThat(configErrors.isEmpty()).isFalse();
    assertThat(configErrors.on(JobConfig.RUN_TYPE)).isEqualTo("Job cannot be set to 'run on all agents' when assigned to an elastic agent");
}
Also used : ConfigErrors(com.thoughtworks.go.domain.ConfigErrors) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigErrors (com.thoughtworks.go.domain.ConfigErrors)52 Test (org.junit.jupiter.api.Test)35 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)6 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Cloner (com.rits.cloning.Cloner)1 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 EnvironmentAgentConfig (com.thoughtworks.go.config.EnvironmentAgentConfig)1 EnvironmentConfig (com.thoughtworks.go.config.EnvironmentConfig)1 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)1 IgnoreTraversal (com.thoughtworks.go.config.IgnoreTraversal)1 Validatable (com.thoughtworks.go.config.Validatable)1 ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)1 GoConfigInvalidMergeException (com.thoughtworks.go.config.exceptions.GoConfigInvalidMergeException)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1