use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertHgMaterialWhenNullName.
@Test
public void shouldConvertHgMaterialWhenNullName() {
CRHgMaterial crHgMaterial = new CRHgMaterial(null, "folder", true, false, filter, "url");
HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) configConverter.toMaterialConfig(crHgMaterial, context);
assertNull(hgMaterialConfig.getName());
assertThat(hgMaterialConfig.getFolder(), is("folder"));
assertThat(hgMaterialConfig.getAutoUpdate(), is(true));
assertThat(hgMaterialConfig.getFilterAsString(), is("filter"));
assertThat(hgMaterialConfig.getUrl(), is("url"));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHgWithWhitelist.
@Test
public void shouldConvertConfigMaterialWhenConfigRepoIsHgWithWhitelist() {
// this url would be configured inside xml config-repo section
HgMaterialConfig configRepoMaterial = new HgMaterialConfig("url", "folder");
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial(null, null, new CRFilter(filter, true));
MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context);
assertNull("shouldSetEmptyMaterialNameAsInConfigRepoSourceCode", materialConfig.getName());
HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
assertThat(hgMaterialConfig.getAutoUpdate(), is(true));
assertThat(hgMaterialConfig.getFilterAsString(), is("filter"));
assertThat(hgMaterialConfig.getUrl(), is("url"));
Filter whitelistFilter = new Filter(new IgnoredFiles("filter"));
assertThat(hgMaterialConfig.filter(), is(whitelistFilter));
assertThat(hgMaterialConfig.isInvertFilter(), is(true));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldAddErrorOnMaterialIfAutoUpdateDoesNotMatchAcrossFingerPrint.
@Test
public void shouldAddErrorOnMaterialIfAutoUpdateDoesNotMatchAcrossFingerPrint() throws Exception {
HgMaterialConfig materialOne = new HgMaterialConfig("http://url1", null);
materialOne.setAutoUpdate(false);
HgMaterialConfig materialTwo = new HgMaterialConfig("http://url1", null);
materialTwo.setAutoUpdate(true);
CruiseConfig config = GoConfigMother.configWithPipelines("one", "two");
PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
pipelineOne.setMaterialConfigs(new MaterialConfigs(materialOne));
PipelineConfig pipelineTwo = config.pipelineConfigByName(new CaseInsensitiveString("two"));
pipelineTwo.setMaterialConfigs(new MaterialConfigs(materialTwo));
pipelineOne.materialConfigs().validate(ConfigSaveValidationContext.forChain(config));
assertThat(pipelineOne.materialConfigs().get(0).errors().on(ScmMaterialConfig.AUTO_UPDATE), is("Material of type Mercurial (http://url1) is specified more than once in the configuration with different values for the autoUpdate attribute. All copies of this material must have the same value for this attribute."));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class ParamResolverTest method shouldResolveInBasicPipelineConfigs.
@Test
public void shouldResolveInBasicPipelineConfigs() throws NoSuchFieldException {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("cruise", "dev", "ant");
pipelineConfig.setLabelTemplate("2.1-${COUNT}-#{foo}-bar-#{bar}");
HgMaterialConfig materialConfig = MaterialConfigsMother.hgMaterialConfig("http://#{foo}.com/#{bar}");
pipelineConfig.addMaterialConfig(materialConfig);
BasicPipelineConfigs pipelines = new BasicPipelineConfigs(pipelineConfig);
new ParamResolver(new ParamSubstitutionHandlerFactory(params(param("foo", "pavan"), param("bar", "jj"))), fieldCache).resolve(pipelines);
assertThat(pipelineConfig.getLabelTemplate(), is("2.1-${COUNT}-pavan-bar-jj"));
assertThat(pipelineConfig.materialConfigs().get(1).getUriForDisplay(), is("http://pavan.com/jj"));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class ParamResolverTest method shouldResolveInMergePipelineConfigs.
@Test
public void shouldResolveInMergePipelineConfigs() throws NoSuchFieldException {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("cruise", "dev", "ant");
pipelineConfig.setLabelTemplate("2.1-${COUNT}-#{foo}-bar-#{bar}");
HgMaterialConfig materialConfig = MaterialConfigsMother.hgMaterialConfig("http://#{foo}.com/#{bar}");
pipelineConfig.addMaterialConfig(materialConfig);
MergePipelineConfigs merge = new MergePipelineConfigs(new BasicPipelineConfigs(), new BasicPipelineConfigs(pipelineConfig));
new ParamResolver(new ParamSubstitutionHandlerFactory(params(param("foo", "pavan"), param("bar", "jj"))), fieldCache).resolve(merge);
assertThat(pipelineConfig.getLabelTemplate(), is("2.1-${COUNT}-pavan-bar-jj"));
assertThat(pipelineConfig.materialConfigs().get(1).getUriForDisplay(), is("http://pavan.com/jj"));
}
Aggregations