use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class ParamResolverTest method shouldResolveCollections.
@Test
public void shouldResolveCollections() 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);
new ParamResolver(new ParamSubstitutionHandlerFactory(params(param("foo", "pavan"), param("bar", "jj"))), fieldCache).resolve(pipelineConfig);
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 shouldLexicallyScopeTheParameters.
@Test
public void shouldLexicallyScopeTheParameters() throws NoSuchFieldException {
PipelineConfig withParams = PipelineConfigMother.createPipelineConfig("cruise", "dev", "ant");
withParams.addParam(param("foo", "pipeline"));
PipelineConfig withoutParams = PipelineConfigMother.createPipelineConfig("mingle", "dev", "ant");
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.addPipeline("group", withParams);
cruiseConfig.addPipeline("group", withoutParams);
cruiseConfig.server().setArtifactsDir("/#{foo}/#{bar}");
HgMaterialConfig materialConfig = MaterialConfigsMother.hgMaterialConfig();
materialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "work/#{foo}/#{bar}/baz"));
withParams.addMaterialConfig(materialConfig);
withParams.setLabelTemplate("2.0.#{foo}-#{bar}");
withoutParams.setLabelTemplate("2.0.#{foo}-#{bar}");
new ParamResolver(new ParamSubstitutionHandlerFactory(params(param("foo", "global"), param("bar", "global-only"))), fieldCache).resolve(cruiseConfig);
assertThat(withParams.materialConfigs().get(1).getFolder(), is("work/pipeline/global-only/baz"));
assertThat(withParams.getLabelTemplate(), is("2.0.pipeline-global-only"));
assertThat(withoutParams.getLabelTemplate(), is("2.0.global-global-only"));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldCheckSCMMaterialsHaveDestinationCorrectly.
@Test
public void shouldCheckSCMMaterialsHaveDestinationCorrectly() {
HgMaterialConfig materialConfigOne = new HgMaterialConfig("http://url1", null);
materialConfigOne.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder"));
CruiseConfig config = GoConfigMother.configWithPipelines("one");
PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
pipelineOne.setMaterialConfigs((new MaterialConfigs(materialConfigOne)));
assertThat(pipelineOne.materialConfigs().scmMaterialsHaveDestination(), is(true));
PluggableSCMMaterialConfig materialConfigTwo = new PluggableSCMMaterialConfig(null, SCMMother.create("scm-id"), null, null);
pipelineOne.materialConfigs().add(materialConfigTwo);
assertThat(pipelineOne.materialConfigs().scmMaterialsHaveDestination(), is(false));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldShowAutoUpdateMismatchErrorTwiceWhenMaterialIsAddedToSamePipeline.
@Test
public void shouldShowAutoUpdateMismatchErrorTwiceWhenMaterialIsAddedToSamePipeline() throws Exception {
HgMaterialConfig materialOne = new HgMaterialConfig("http://url1", null);
materialOne.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "some-folder"));
materialOne.setAutoUpdate(true);
HgMaterialConfig materialTwo = new HgMaterialConfig("http://url1", null);
materialTwo.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "some-folder-2"));
materialTwo.setAutoUpdate(false);
CruiseConfig config = GoConfigMother.configWithPipelines("one");
PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
pipelineOne.setMaterialConfigs(new MaterialConfigs(materialOne, materialTwo));
pipelineOne.materialConfigs().validate(ConfigSaveValidationContext.forChain(config));
assertThat(pipelineOne.materialConfigs().get(0).errors().getAll().size(), is(1));
assertThat(pipelineOne.materialConfigs().get(1).errors().getAll().size(), is(1));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldReturnMaterialBasedOnPiplineUniqueFingerPrint.
@Test
public void shouldReturnMaterialBasedOnPiplineUniqueFingerPrint() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
HgMaterialConfig expectedMaterial = MaterialConfigsMother.hgMaterialConfig();
pipeline1.addMaterialConfig(expectedMaterial);
pipeline1.addMaterialConfig(MaterialConfigsMother.gitMaterialConfig("url"));
pipeline1.addMaterialConfig(MaterialConfigsMother.svnMaterialConfig("url", "folder"));
MaterialConfig actualMaterialConfig = pipeline1.materialConfigs().getByFingerPrint(expectedMaterial.getPipelineUniqueFingerprint());
assertThat(actualMaterialConfig, is(expectedMaterial));
}
Aggregations