use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.
the class PluggableSCMMaterialConfigTest method shouldAddErrorIfMaterialDoesNotHaveASCMId.
@Test
public void shouldAddErrorIfMaterialDoesNotHaveASCMId() {
pluggableSCMMaterialConfig.setScmId(null);
pluggableSCMMaterialConfig.validateConcreteMaterial(new ConfigSaveValidationContext(null, null));
assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(1));
assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.SCM_ID), is("Please select a SCM"));
}
use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.
the class PluggableSCMMaterialConfigTest method shouldAddErrorIDestinationIsNotValid.
@Test
public void shouldAddErrorIDestinationIsNotValid() throws Exception {
ConfigSaveValidationContext configSaveValidationContext = mock(ConfigSaveValidationContext.class);
SCM scmConfig = mock(SCM.class);
when(configSaveValidationContext.findScmById(anyString())).thenReturn(scmConfig);
when(scmConfig.doesPluginExist()).thenReturn(true);
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(null, scmConfig, "/usr/home", null, false);
pluggableSCMMaterialConfig.setScmId("scm-id");
pluggableSCMMaterialConfig.validateConcreteMaterial(configSaveValidationContext);
assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(1));
assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.FOLDER), is("Dest folder '/usr/home' is not valid. It must be a sub-directory of the working folder."));
pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(null, scmConfig, "./../crap", null, false);
pluggableSCMMaterialConfig.setScmId("scm-id");
pluggableSCMMaterialConfig.validateConcreteMaterial(configSaveValidationContext);
assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(2));
assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.FOLDER), is("Invalid directory name './../crap'. It should be a valid relative path."));
}
use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.
the class ElasticProfileTest method shouldNotAddAnyErrorsForAValidClusterProfileReference.
@Test
public void shouldNotAddAnyErrorsForAValidClusterProfileReference() {
ElasticProfile profile = new ElasticProfile("docker.unit-test", "prod-cluster");
BasicCruiseConfig config = new BasicCruiseConfig();
config.getElasticConfig().setClusterProfiles(new ClusterProfiles(new ClusterProfile("prod-cluster", "cd.go.elastic-agent.docker")));
profile.validate(new ConfigSaveValidationContext(config));
assertThat(profile.errors().size(), is(0));
}
use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.
the class PackageRepositoryTest method shouldValidateIfNameIsMissing.
@Test
void shouldValidateIfNameIsMissing() {
PackageRepository packageRepository = new PackageRepository();
packageRepository.validate(new ConfigSaveValidationContext(new BasicCruiseConfig(), null));
assertThat(packageRepository.errors().getAllOn("name")).isEqualTo(asList("Please provide name"));
}
use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.
the class PackageRepositoryTest method shouldValidateName.
@Test
void shouldValidateName() throws Exception {
PackageRepository packageRepository = new PackageRepository();
packageRepository.setName("some name");
packageRepository.validate(new ConfigSaveValidationContext(null));
assertThat(packageRepository.errors().isEmpty()).isFalse();
assertThat(packageRepository.errors().getAllOn(PackageRepository.NAME).get(0)).isEqualTo("Invalid PackageRepository name 'some 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.");
}
Aggregations