use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class CachedGoConfigIntegrationTest method setupExternalConfigRepoWithDependencyMaterialOnPipelineInMainXml.
private void setupExternalConfigRepoWithDependencyMaterialOnPipelineInMainXml(String upstream, String remoteDownstreamPipelineName) {
PipelineConfig upstreamPipelineConfig = GoConfigMother.createPipelineConfigWithMaterialConfig(upstream, new GitMaterialConfig("FOO"));
goConfigService.addPipeline(upstreamPipelineConfig, "default");
PartialConfig partialConfig = PartialConfigMother.pipelineWithDependencyMaterial(remoteDownstreamPipelineName, upstreamPipelineConfig, new RepoConfigOrigin(configRepo, "r1"));
goPartialConfig.onSuccessPartialConfig(configRepo, partialConfig);
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class CachedGoConfigIntegrationTest method shouldUpdateConfigWithValidPartialsAndInvalidKnownPartials.
@Test
public void shouldUpdateConfigWithValidPartialsAndInvalidKnownPartials() throws GitAPIException, IOException {
String gitShaBeforeSave = configRepository.getCurrentRevCommit().getName();
PartialConfig validPartial = PartialConfigMother.withPipeline("remote_pipeline", new RepoConfigOrigin(configRepo, "revision1"));
PartialConfig invalidPartial = PartialConfigMother.invalidPartial("invalid", new RepoConfigOrigin(configRepo, "revision2"));
goPartialConfig.onSuccessPartialConfig(configRepo, validPartial);
goPartialConfig.onSuccessPartialConfig(configRepo, invalidPartial);
assertTrue(cachedGoPartials.lastValidPartials().contains(validPartial));
assertTrue(cachedGoPartials.lastKnownPartials().contains(invalidPartial));
CruiseConfig config = new Cloner().deepClone(cachedGoConfig.loadForEditing());
config.addEnvironment(UUID.randomUUID().toString());
ConfigSaveState state = cachedGoConfig.writeFullConfigWithLock(new FullConfigUpdateCommand(config, goConfigService.configFileMd5()));
String gitShaAfterSave = configRepository.getCurrentRevCommit().getName();
String configXmlFromConfigFolder = FileUtils.readFileToString(new File(goConfigDao.fileLocation()), UTF_8);
assertThat(state, is(ConfigSaveState.UPDATED));
assertThat(cachedGoConfig.loadForEditing(), is(config));
assertNotEquals(gitShaBeforeSave, gitShaAfterSave);
assertThat(cachedGoConfig.loadForEditing().getMd5(), is(configRepository.getCurrentRevision().getMd5()));
assertThat(cachedGoConfig.currentConfig().getMd5(), is(configRepository.getCurrentRevision().getMd5()));
assertThat(configXmlFromConfigFolder, is(configRepository.getCurrentRevision().getContent()));
assertTrue(cachedGoPartials.lastValidPartials().contains(validPartial));
assertTrue(cachedGoPartials.lastKnownPartials().contains(invalidPartial));
}
Aggregations