use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class ServerHealthServiceTest method stateRelatedPipelineNames.
@Test
public void stateRelatedPipelineNames() {
HgMaterial hgMaterial = MaterialsMother.hgMaterial();
CruiseConfig config = new BasicCruiseConfig();
config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config())));
config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config())));
config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3"));
serverHealthService = new ServerHealthService();
serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forPipeline(PIPELINE_NAME))));
assertThat((serverHealthService.logs().get(0)).getPipelineNames(config), equalTo(Collections.singleton(PIPELINE_NAME)));
serverHealthService = new ServerHealthService();
serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forStage(PIPELINE_NAME, "stage1"))));
assertThat((serverHealthService.logs().get(0)).getPipelineNames(config), equalTo(Collections.singleton(PIPELINE_NAME)));
serverHealthService = new ServerHealthService();
serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forJob(PIPELINE_NAME, "stage1", "job1"))));
assertThat((serverHealthService.logs().get(0)).getPipelineNames(config), equalTo(Collections.singleton(PIPELINE_NAME)));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class ServerHealthServiceTest method noPipelineMatchMaterialStateRelatedPipelineNames.
@Test
public void noPipelineMatchMaterialStateRelatedPipelineNames() {
HgMaterial hgMaterial = MaterialsMother.hgMaterial();
CruiseConfig config = new BasicCruiseConfig();
config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config())));
config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config())));
config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3"));
serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forMaterial(MaterialsMother.p4Material()))));
assertTrue((serverHealthService.logs().get(0)).getPipelineNames(config).isEmpty());
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class ServerHealthServiceTest method materialUpdateStateRelatedPipelineNames.
@Test
public void materialUpdateStateRelatedPipelineNames() {
HgMaterial hgMaterial = MaterialsMother.hgMaterial();
CruiseConfig config = new BasicCruiseConfig();
config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config())));
config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config())));
config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3"));
serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forMaterialUpdate(hgMaterial))));
Set<String> pipelines = (serverHealthService.logs().get(0)).getPipelineNames(config);
assertEquals(Sets.newHashSet("pipeline", "pipeline2"), pipelines);
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class PipelineInstanceModelTest method shouldThrowExceptionWhenCurrentRevisionForUnknownMaterialNameRequested.
@Test
public void shouldThrowExceptionWhenCurrentRevisionForUnknownMaterialNameRequested() {
HgMaterial material = MaterialsMother.hgMaterial();
material.setName(new CaseInsensitiveString("foo"));
try {
assertThat(setUpModificationFor(material).getCurrentRevision("blah").getRevision(), is("a087402bd2a7828a130c1bdf43f2d9ef8f48fd46"));
fail("should have raised an exeption for unknown material name");
} catch (Exception ignored) {
}
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class PipelineInstanceModelTest method shouldReturnIfAnyMaterialHasModifications.
@Test
public void shouldReturnIfAnyMaterialHasModifications() {
final SvnMaterial svnMaterial = svnMaterial("http://svnurl");
final HgMaterial hgMaterial = hgMaterial("http://hgurl", "hgdir");
MaterialRevisions currentRevisions = ModificationsMother.getMaterialRevisions(new HashMap<Material, String>() {
{
put(svnMaterial, "1");
put(hgMaterial, "a");
}
});
MaterialRevisions latestRevisions = ModificationsMother.getMaterialRevisions(new HashMap<Material, String>() {
{
put(svnMaterial, "1");
put(hgMaterial, "b");
}
});
MaterialConfigs materialConfigs = new MaterialConfigs();
materialConfigs.add(svnMaterial.config());
materialConfigs.add(hgMaterial.config());
StageInstanceModels stages = new StageInstanceModels();
stages.addStage("unit1", JobHistory.withJob("test", JobState.Completed, JobResult.Passed, new Date()));
stages.addFutureStage("unit2", false);
PipelineInstanceModel model = PipelineInstanceModel.createPipeline("pipeline", -1, "label", BuildCause.createWithModifications(currentRevisions, ""), stages);
model.setLatestRevisions(latestRevisions);
model.setMaterialConfigs(materialConfigs);
assertThat("svnMaterial hasNewRevisions", model.hasNewRevisions(svnMaterial.config()), is(false));
assertThat("hgMaterial hasNewRevisions", model.hasNewRevisions(hgMaterial.config()), is(true));
assertThat("all materials hasNewRevisions", model.hasNewRevisions(), is(true));
}
Aggregations