Search in sources :

Example 56 with TimeProvider

use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.

the class PipelineScheduleQueueIntegrationTest method shouldPersistTriggerTimeEnvironmentVariable.

@Test
public void shouldPersistTriggerTimeEnvironmentVariable() {
    PipelineConfig pipelineConfig = fixture.pipelineConfig();
    pipelineConfig.setVariables(env("blahVariable", "blahValue"));
    BuildCause cause = modifySomeFilesAndTriggerAs(pipelineConfig, "cruise-developer");
    EnvironmentVariables environmentVariables = new EnvironmentVariables();
    environmentVariables.add(new EnvironmentVariable("blahVariable", "blahOverride"));
    cause.addOverriddenVariables(environmentVariables);
    saveRev(cause);
    queue.schedule(fixture.pipelineName, cause);
    Pipeline pipeline = queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
    assertThat(pipeline.scheduleTimeVariables(), is(new EnvironmentVariables(Arrays.asList(new EnvironmentVariable("blahVariable", "blahOverride")))));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 57 with TimeProvider

use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.

the class PipelineScheduleQueueIntegrationTest method shouldReturnNullIfBuildCauseIsTrumped.

@Test
public void shouldReturnNullIfBuildCauseIsTrumped() throws Exception {
    PipelineConfig pipelineConfig = fixture.pipelineConfig();
    BuildCause cause = modifySomeFiles(pipelineConfig, ModificationsMother.currentRevision());
    queue.schedule(fixture.pipelineName, cause);
    queue.finishSchedule(fixture.pipelineName, cause, cause);
    assertThat(queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider()), is(nullValue()));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 58 with TimeProvider

use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.

the class PipelineScheduleQueueIntegrationTest method shouldBeCanceledWhenSameBuildCause.

@Test
public void shouldBeCanceledWhenSameBuildCause() throws Exception {
    PipelineConfig pipelineConfig = fixture.pipelineConfig();
    BuildCause cause = modifySomeFiles(pipelineConfig, ModificationsMother.currentRevision());
    queue.finishSchedule(fixture.pipelineName, cause, cause);
    queue.schedule(fixture.pipelineName, cause);
    assertThat(fixture.pipelineName, is(scheduledOn(queue)));
    assertThat(queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider()), is(nullValue()));
    assertThat(fixture.pipelineName, is(not(scheduledOn(queue))));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 59 with TimeProvider

use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.

the class PipelineScheduleQueueIntegrationTest method shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision.

@Test
public void shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision() {
    PipelineConfig pipelineConfig = fixture.pipelineConfig();
    BuildCause cause = modifySomeFilesAndTriggerAs(pipelineConfig, "cruise-developer");
    MaterialConfig materialConfig = pipelineConfig.materialConfigs().first();
    cause.getMaterialRevisions().findRevisionFor(materialConfig);
    pipelineConfig.setOrigins(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig, "123"), "plug"));
    saveRev(cause);
    queue.schedule(fixture.pipelineName, cause);
    Pipeline pipeline = queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
    assertThat(pipeline, is(nullValue()));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 60 with TimeProvider

use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.

the class PipelineScheduleQueueIntegrationTest method shouldSaveCurrentConfigMD5OnStageWhenSchedulingAPipeline.

@Test
public void shouldSaveCurrentConfigMD5OnStageWhenSchedulingAPipeline() {
    PipelineConfig pipelineConfig = fixture.pipelineConfig();
    BuildCause cause = modifySomeFilesAndTriggerAs(pipelineConfig, "cruise-developer");
    EnvironmentVariables environmentVariables = new EnvironmentVariables();
    environmentVariables.add(new EnvironmentVariable("blahVariable", "blahOverride"));
    cause.addOverriddenVariables(environmentVariables);
    saveRev(cause);
    queue.schedule(fixture.pipelineName, cause);
    Pipeline pipeline = queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
    assertThat(pipeline.getFirstStage().getConfigVersion(), is("md5-test"));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Aggregations

TimeProvider (com.thoughtworks.go.util.TimeProvider)177 Test (org.junit.Test)122 Date (java.util.Date)29 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)28 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)25 DateTime (org.joda.time.DateTime)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 GoConfigRevision (com.thoughtworks.go.domain.GoConfigRevision)13 Username (com.thoughtworks.go.server.domain.Username)13 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 Before (org.junit.Before)13 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)11 Materials (com.thoughtworks.go.config.materials.Materials)10 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)10 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)9 TransactionStatus (org.springframework.transaction.TransactionStatus)9 Material (com.thoughtworks.go.domain.materials.Material)7 Modification (com.thoughtworks.go.domain.materials.Modification)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)6