Search in sources :

Example 96 with RepoConfigOrigin

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);
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin)

Example 97 with RepoConfigOrigin

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));
}
Also used : FullConfigUpdateCommand(com.thoughtworks.go.config.update.FullConfigUpdateCommand) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) StringContains.containsString(org.hamcrest.core.StringContains.containsString) File(java.io.File) Cloner(com.rits.cloning.Cloner)

Aggregations

RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)97 Test (org.junit.Test)74 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)34 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)29 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)23 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)15 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)13 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)11 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)11 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)11 StringContains.containsString (org.hamcrest.core.StringContains.containsString)11 File (java.io.File)9 IOException (java.io.IOException)8 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)8 ExpectedException (org.junit.rules.ExpectedException)8 Cloner (com.rits.cloning.Cloner)7 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)7 Modification (com.thoughtworks.go.domain.materials.Modification)7 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)6 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)6