use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class ConfigRepoConfigTest method validate_shouldNotAllowDisabledAutoUpdate.
@Test
public void validate_shouldNotAllowDisabledAutoUpdate() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
GoConfigMother mother = new GoConfigMother();
SvnMaterialConfig svn = new SvnMaterialConfig("url", false);
svn.setAutoUpdate(false);
ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(svn, "plug");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
configRepoConfig.validate(null);
assertThat(configRepoConfig.errors().isEmpty(), is(false));
assertThat(configRepoConfig.errors().on(ConfigRepoConfig.AUTO_UPDATE), is("Configuration repository material url must have autoUpdate enabled"));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class ConfigRepoConfigTest method validate_shouldNotAllowPipelineWithSameRepositoryAndDisabledAutoUpdate.
@Test
public void validate_shouldNotAllowPipelineWithSameRepositoryAndDisabledAutoUpdate() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
GoConfigMother mother = new GoConfigMother();
MaterialConfigs materialConfigs = new MaterialConfigs();
SvnMaterialConfig svn = new SvnMaterialConfig("url", false);
svn.setAutoUpdate(false);
materialConfigs.add(svn);
ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(svn, "plug");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
PipelineConfig pipeline1 = mother.addPipeline(cruiseConfig, "badpipe", "build", materialConfigs, "build");
configRepoConfig.validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
assertThat(svn.errors().isEmpty(), is(false));
assertThat(svn.errors().on(ScmMaterialConfig.AUTO_UPDATE), is("Material of type Subversion (url) is specified as a configuration repository and pipeline material with disabled autoUpdate. All copies of this material must have autoUpdate enabled or configuration repository must be removed"));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnInvalidWhenPipelineGroupPartialHasInvalidAttributeValue.
@Test
public void shouldReturnInvalidWhenPipelineGroupPartialHasInvalidAttributeValue() throws Exception {
String groupName = "group_name";
String md5 = "md5";
cruiseConfig = new BasicCruiseConfig();
expectLoad(cruiseConfig);
new GoConfigMother().addPipelineWithGroup(cruiseConfig, groupName, "pipeline_name", "stage_name", "job_name");
expectLoadForEditing(cruiseConfig);
when(goConfigDao.md5OfConfigFile()).thenReturn(md5);
String pipelineGroupContent = groupXmlWithInvalidAttributeValue(groupName);
GoConfigValidity validity = goConfigService.groupSaver(groupName).saveXml(pipelineGroupContent, "md5");
assertThat(validity.isValid(), Matchers.is(false));
assertThat(validity.errorMessage(), containsString("Name is invalid. \"pipeline@$^\""));
verify(goConfigDao, never()).updateConfig(any(UpdateConfigCommand.class));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldRegisterBaseUrlChangeListener.
@Test
public void shouldRegisterBaseUrlChangeListener() throws Exception {
CruiseConfig cruiseConfig = new GoConfigMother().cruiseConfigWithOnePipelineGroup();
stub(goConfigDao.load()).toReturn(cruiseConfig);
goConfigService.initialize();
verify(goConfigDao).registerListener(any(BaseUrlChangeListener.class));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class PipelineConfigsServiceTest method shouldReturnXmlForGivenGroup_onGetXml.
@Test
public void shouldReturnXmlForGivenGroup_onGetXml() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
String groupName = "group_name";
new GoConfigMother().addPipelineWithGroup(cruiseConfig, groupName, "pipeline_name", "stage_name", "job_name");
when(goConfigService.getConfigForEditing()).thenReturn(cruiseConfig);
when(securityService.isUserAdminOfGroup(validUser.getUsername(), groupName)).thenReturn(true);
String actualXml = service.getXml(groupName, validUser, result);
String expectedXml = "<pipelines group=\"group_name\">\n <pipeline name=\"pipeline_name\">\n <materials>\n <svn url=\"file:///tmp/foo\" />\n </materials>\n <stage name=\"stage_name\">\n <jobs>\n <job name=\"job_name\" />\n </jobs>\n </stage>\n </pipeline>\n</pipelines>";
assertThat(actualXml, is(expectedXml));
assertThat(result.isSuccessful(), is(true));
verify(goConfigService, times(1)).getConfigForEditing();
}
Aggregations