use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class PackageMaterialSaveCommandTestBase method setup.
@Before
public void setup() throws Exception {
initMocks(this);
cruiseConfig = GoConfigMother.configWithPackageRepo("repo1");
pipelineName = "test";
PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig(pipelineName);
PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
pipelineConfig.materialConfigs().add(0, new PackageMaterialConfig(null, "repo1-pkg-1", packageDefinition));
pipelineGroup = "grp1";
cruiseConfig.addPipeline(pipelineGroup, pipelineConfig);
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class AbstractMaterialConfigTest method shouldNotUseNameFieldButInsteadUseTheNameMethodToCheckIfTheMaterialNameIsUsedInThePipelineLabel.
@Test
void shouldNotUseNameFieldButInsteadUseTheNameMethodToCheckIfTheMaterialNameIsUsedInThePipelineLabel() throws Exception {
PipelineConfig pipelineConfig = mock(PipelineConfig.class);
when(pipelineConfig.getLabelTemplate()).thenReturn("${COUNT}-${hg}-${dep}-${pkg}-${scm}");
MaterialConfig hg = mock(HgMaterialConfig.class);
when(hg.getName()).thenReturn(new CaseInsensitiveString("hg"));
when(hg.isUsedInLabelTemplate(pipelineConfig)).thenCallRealMethod();
MaterialConfig dependency = mock(DependencyMaterialConfig.class);
when(dependency.getName()).thenReturn(new CaseInsensitiveString("dep"));
when(dependency.isUsedInLabelTemplate(pipelineConfig)).thenCallRealMethod();
MaterialConfig aPackage = mock(PackageMaterialConfig.class);
when(aPackage.getName()).thenReturn(new CaseInsensitiveString("pkg"));
when(aPackage.isUsedInLabelTemplate(pipelineConfig)).thenCallRealMethod();
MaterialConfig aPluggableSCM = mock(PluggableSCMMaterialConfig.class);
when(aPluggableSCM.getName()).thenReturn(new CaseInsensitiveString("scm"));
when(aPluggableSCM.isUsedInLabelTemplate(pipelineConfig)).thenCallRealMethod();
assertThat(hg.isUsedInLabelTemplate(pipelineConfig)).isTrue();
assertThat(dependency.isUsedInLabelTemplate(pipelineConfig)).isTrue();
assertThat(aPackage.isUsedInLabelTemplate(pipelineConfig)).isTrue();
assertThat(aPluggableSCM.isUsedInLabelTemplate(pipelineConfig)).isTrue();
verify(hg).getName();
verify(dependency).getName();
verify(aPackage).getName();
verify(aPluggableSCM).getName();
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials.
@Test
public void shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials() throws SQLException {
String p4view = "//depot/... //localhost/...";
Materials p4Materials = MaterialsMother.p4Materials(p4view);
P4Material p4Material = (P4Material) p4Materials.first();
p4Material.setUseTickets(true);
PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
pipelineConfig.setMaterialConfigs(p4Materials.convertToConfigs());
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
assertNotInserted(pipeline.getId());
savePipeline(pipeline);
Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
Materials materials = pipelineFromDB.getMaterials();
assertThat(materials.get(0), is(p4Material));
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveDependencyMaterials.
@Test
public void shouldStoreAndRetrieveDependencyMaterials() throws SQLException {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
pipelineConfig.setMaterialConfigs(new MaterialConfigs(dependencyMaterial.config()));
MaterialRevisions materialRevisions = new MaterialRevisions();
materialRevisions.addRevision(DependencyMaterialRevision.create("pipeline-name", -12, "1234", "stage-name", 1).convert(dependencyMaterial, new Date()));
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
assertNotInserted(pipeline.getId());
savePipeline(pipeline);
Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
final Materials materials = pipelineFromDB.getMaterials();
assertThat(materials.get(0), is(dependencyMaterial));
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldSupportSubmoduleFolderInGitMaterials.
@Test
public void shouldSupportSubmoduleFolderInGitMaterials() throws Exception {
Materials materials = MaterialsMother.gitMaterials("gitUrl", "submoduleFolder", null);
PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
pipelineConfig.setMaterialConfigs(materials.convertToConfigs());
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
assertNotInserted(pipeline.getId());
save(pipeline);
Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
Materials materialsFromDB = pipelineFromDB.getMaterials();
GitMaterial gitMaterial = (GitMaterial) materialsFromDB.get(0);
assertThat(gitMaterial.getSubmoduleFolder(), is("submoduleFolder"));
}
Aggregations