Search in sources :

Example 1 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class XmlPartialConfigProviderTest method shouldParseFileWithOnePipeline.

@Test
public void shouldParseFileWithOnePipeline() throws Exception {
    GoConfigMother mother = new GoConfigMother();
    PipelineConfig pipe1 = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
    File file = helper.addFileWithPipeline("pipe1.gocd.xml", pipe1);
    PartialConfig part = xmlPartialProvider.parseFile(file);
    PipelineConfig pipeRead = part.getGroups().get(0).get(0);
    assertThat(pipeRead, is(pipe1));
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) File(java.io.File) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.Test)

Example 2 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class XmlPartialConfigProviderTest method shouldLoadDirectoryWithOnePipeline.

@Test
public void shouldLoadDirectoryWithOnePipeline() throws Exception {
    GoConfigMother mother = new GoConfigMother();
    PipelineConfig pipe1 = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
    helper.addFileWithPipeline("pipe1.gocd.xml", pipe1);
    PartialConfig part = xmlPartialProvider.load(tmpFolder, mock(PartialConfigLoadContext.class));
    PipelineConfig pipeRead = part.getGroups().get(0).get(0);
    assertThat(pipeRead, is(pipe1));
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.Test)

Example 3 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class XmlPartialConfigProviderTest method shouldLoadDirectoryWithOnePipelineGroup.

@Test
public void shouldLoadDirectoryWithOnePipelineGroup() throws Exception {
    GoConfigMother mother = new GoConfigMother();
    PipelineConfigs group1 = mother.cruiseConfigWithOnePipelineGroup().getGroups().get(0);
    helper.addFileWithPipelineGroup("group1.gocd.xml", group1);
    PartialConfig part = xmlPartialProvider.load(tmpFolder, mock(PartialConfigLoadContext.class));
    PipelineConfigs groupRead = part.getGroups().get(0);
    assertThat(groupRead, is(group1));
    assertThat(groupRead.size(), is(group1.size()));
    assertThat(groupRead.get(0), is(group1.get(0)));
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.Test)

Example 4 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class PartialConfigHelper method addFileWithEnvironment.

public File addFileWithEnvironment(String relativePath, EnvironmentConfig env) throws Exception {
    PartialConfig partialConfig = new PartialConfig();
    partialConfig.getEnvironments().add(env);
    return this.addFileWithPartialConfig(relativePath, partialConfig);
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig)

Example 5 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class GoFileConfigDataSourceIntegrationTest method shouldFallbackToValidPartialsForConfigChangesThroughFileSystem.

@Test
public void shouldFallbackToValidPartialsForConfigChangesThroughFileSystem() throws Exception {
    assertThat(goConfigService.getCurrentConfig().getAllPipelineNames().contains(new CaseInsensitiveString(remoteDownstream)), is(true));
    String remoteInvalidPipeline = "remote_invalid_pipeline";
    PartialConfig invalidPartial = PartialConfigMother.invalidPartial(remoteInvalidPipeline, new RepoConfigOrigin(configRepo, "r2"));
    goPartialConfig.onSuccessPartialConfig(configRepo, invalidPartial);
    assertThat(goConfigService.getCurrentConfig().getAllPipelineNames().contains(new CaseInsensitiveString(remoteInvalidPipeline)), is(false));
    final String newArtifactLocation = "some_random_change_to_config";
    updateConfigOnFileSystem(new UpdateConfig() {

        @Override
        public void update(CruiseConfig cruiseConfig) {
            cruiseConfig.server().setArtifactsDir(newArtifactLocation);
        }
    });
    GoConfigHolder goConfigHolder = dataSource.forceLoad(new File(systemEnvironment.getCruiseConfigFile()));
    assertThat(goConfigHolder.config.server().artifactsDir(), is(newArtifactLocation));
    assertThat(goConfigHolder.config.getAllPipelineNames().contains(new CaseInsensitiveString(remoteDownstream)), is(true));
    assertThat(goConfigHolder.config.getAllPipelineNames().contains(new CaseInsensitiveString(remoteInvalidPipeline)), is(false));
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) File(java.io.File) Test(org.junit.Test)

Aggregations

PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)66 Test (org.junit.Test)40 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)28 File (java.io.File)15 StringContains.containsString (org.hamcrest.core.StringContains.containsString)12 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)11 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)10 IOException (java.io.IOException)8 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)8 ExpectedException (org.junit.rules.ExpectedException)8 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)7 Cloner (com.rits.cloning.Cloner)6 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)6 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)5 ConfigFileHasChangedException (com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException)4 ConfigMergeException (com.thoughtworks.go.config.exceptions.ConfigMergeException)4 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)4 PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)4 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 Arrays.asList (java.util.Arrays.asList)3