use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldValidateConfigRepoLastKnownPartialsWithMainConfigAndUpdateConfigToIncludePipelinesFromPartials.
@Test
public void shouldValidateConfigRepoLastKnownPartialsWithMainConfigAndUpdateConfigToIncludePipelinesFromPartials() {
String pipelineFromConfigRepo = "pipeline_from_config_repo";
final String pipelineInMain = "pipeline_in_main";
PartialConfig partialConfig = PartialConfigMother.withPipeline(pipelineFromConfigRepo, new RepoConfigOrigin(repoConfig, "1"));
cachedGoPartials.addOrUpdate(repoConfig.getMaterialConfig().getFingerprint(), partialConfig);
assertThat(cachedGoPartials.lastValidPartials().isEmpty(), is(true));
GoFileConfigDataSource.GoConfigSaveResult result = dataSource.writeWithLock(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
cruiseConfig.addPipeline("default", PipelineConfigMother.createPipelineConfig(pipelineInMain, "stage", "job"));
return cruiseConfig;
}
}, new GoConfigHolder(configHelper.currentConfig(), configHelper.currentConfig()));
assertThat(result.getConfigHolder().config.getAllPipelineNames().contains(new CaseInsensitiveString(pipelineFromConfigRepo)), is(true));
assertThat(result.getConfigHolder().config.getAllPipelineNames().contains(new CaseInsensitiveString(pipelineInMain)), is(true));
assertThat(cachedGoPartials.lastValidPartials().size(), is(1));
PartialConfig actualPartial = cachedGoPartials.lastValidPartials().get(0);
assertThat(actualPartial.getGroups(), is(partialConfig.getGroups()));
assertThat(actualPartial.getEnvironments(), is(partialConfig.getEnvironments()));
assertThat(actualPartial.getOrigin(), is(partialConfig.getOrigin()));
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class GoPartialConfigTest method shouldReturnLatestPartialAfterCheckout_AndWatchListNotEmpty.
@Test
public void shouldReturnLatestPartialAfterCheckout_AndWatchListNotEmpty() throws Exception {
ScmMaterialConfig material = setOneConfigRepo();
PartialConfig part = new PartialConfig();
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(part);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
assertThat(partialConfig.lastPartials().size(), is(1));
assertThat(partialConfig.lastPartials().get(0), is(part));
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class GoPartialConfigTest method shouldReturnEmptyList_WhenFirstParsingFailed.
@Test
public void shouldReturnEmptyList_WhenFirstParsingFailed() {
ScmMaterialConfig material = setOneConfigRepo();
PartialConfig part = new PartialConfig();
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenThrow(new RuntimeException("Failed parsing"));
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
assertThat(repoConfigDataSource.latestParseHasFailedForMaterial(material), is(true));
assertThat(partialConfig.lastPartials().size(), is(0));
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class GoPartialConfigTest method shouldReturnFirstPartial_WhenFirstParsedSucceed_ButSecondFailed.
@Test
public void shouldReturnFirstPartial_WhenFirstParsedSucceed_ButSecondFailed() throws Exception {
ScmMaterialConfig material = setOneConfigRepo();
PartialConfig part = new PartialConfig();
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(part);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenThrow(new RuntimeException("Failed parsing"));
repoConfigDataSource.onCheckoutComplete(material, folder, "6354");
assertThat(repoConfigDataSource.latestParseHasFailedForMaterial(material), is(true));
assertThat(partialConfig.lastPartials().size(), is(1));
assertThat(partialConfig.lastPartials().get(0), is(part));
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class CachedGoPartials method markAsValid.
public void markAsValid(List<PartialConfig> partials) {
for (PartialConfig partial : partials) {
if (partial.getOrigin() instanceof RepoConfigOrigin) {
String fingerprint = ((RepoConfigOrigin) partial.getOrigin()).getMaterial().getFingerprint();
markAsValid(fingerprint, partial);
}
}
}
Aggregations