Search in sources :

Example 36 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldLoadMostRecentPipeline.

// TODO FIXME sorted by Id is not good.
// - Comment by Bobby: Sorted by Id is exactly what we want here. Please discuss.
@Test
public void shouldLoadMostRecentPipeline() throws Exception {
    String stageName = "dev";
    PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", stageName);
    Pipeline mingle = schedulePipelineWithStages(mingleConfig);
    Pipeline mostRecentPipeline = pipelineDao.mostRecentPipeline(mingle.getName());
    assertThat(mostRecentPipeline, hasSameId(mingle));
    assertThat(mostRecentPipeline.getBuildCause().getMaterialRevisions().totalNumberOfModifications(), is(1));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 37 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldReturnStageIdOfPassedRunIfThereWereMultipleRerunsOfAStageAndOneOfThemPassed.

@Test
public void shouldReturnStageIdOfPassedRunIfThereWereMultipleRerunsOfAStageAndOneOfThemPassed() throws SQLException {
    String pipelineName = "some-pipeline";
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig(pipelineName);
    Pipeline pipeline = dbHelper.schedulePipelineWithAllStages(pipelineConfig, ModificationsMother.modifySomeFiles(pipelineConfig));
    dbHelper.pass(pipeline);
    Stage stage = dbHelper.scheduleStage(pipeline, pipelineConfig.getFirstStageConfig());
    dbHelper.cancelStage(stage);
    String stageName = pipelineConfig.get(0).name().toString();
    assertThat(pipelineDao.latestPassedStageIdentifier(pipeline.getId(), stageName), is(new StageIdentifier(pipelineName, pipeline.getCounter(), pipeline.getLabel(), stageName, "1")));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 38 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldIncrementCounter_WhenPipelineRowIsPresentWhichWasInsertedByPauseAction.

@Test
public void shouldIncrementCounter_WhenPipelineRowIsPresentWhichWasInsertedByPauseAction() throws SQLException {
    String pipelineName = "some-pipeline";
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig(pipelineName);
    // Counter is 1
    Pipeline pipeline = dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
    // Counter should be incremented
    dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
    assertThat(pipelineDao.getCounterForPipeline(pipeline.getName().toUpperCase()), is(pipeline.getCounter() + 1));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 39 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveSvnMaterials.

@Test
public void shouldStoreAndRetrieveSvnMaterials() throws SQLException {
    SvnMaterial svnMaterial = svnMaterial("svnUrl", "folder");
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(new MaterialConfigs(svnMaterial.config()));
    MaterialRevisions materialRevisions = new MaterialRevisions();
    materialRevisions.addRevision(svnMaterial, ModificationsMother.multipleModificationList());
    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(svnMaterial));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.jupiter.api.Test)

Example 40 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldPauseExistingPipeline.

@Test
public void shouldPauseExistingPipeline() throws Exception {
    PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("some-pipeline", "dev");
    schedulePipelineWithStages(mingleConfig);
    pipelineDao.pause(mingleConfig.name().toString(), "cause", "by");
    PipelinePauseInfo actual = pipelineDao.pauseState(mingleConfig.name().toString());
    PipelinePauseInfo expected = new PipelinePauseInfo(true, "cause", "by");
    assertThat(actual.isPaused(), is(expected.isPaused()));
    assertThat(actual.getPauseCause(), is(expected.getPauseCause()));
    assertThat(actual.getPauseBy(), is(expected.getPauseBy()));
    assertNotNull(actual.getPausedAt());
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Test(org.junit.jupiter.api.Test)

Aggregations

PipelineConfig (com.thoughtworks.go.config.PipelineConfig)285 Test (org.junit.jupiter.api.Test)185 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)142 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)52 TimeProvider (com.thoughtworks.go.util.TimeProvider)33 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)24 Test (org.junit.Test)23 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)21 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)19 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 Materials (com.thoughtworks.go.config.materials.Materials)14 Date (java.util.Date)14 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)13 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)13 StageConfig (com.thoughtworks.go.config.StageConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 Pipeline (com.thoughtworks.go.domain.Pipeline)12 Modification (com.thoughtworks.go.domain.materials.Modification)12