Search in sources :

Example 51 with PartialConfig

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

the class PartialConfigHelper method addFileWithPipelineGroup.

public File addFileWithPipelineGroup(String relativePath, PipelineConfigs group) throws Exception {
    PartialConfig partialConfig = new PartialConfig();
    partialConfig.getGroups().add(group);
    return this.addFileWithPartialConfig(relativePath, partialConfig);
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig)

Example 52 with PartialConfig

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

the class PartialConfigHelper method addFileWithPipeline.

public File addFileWithPipeline(String relativePath, PipelineConfig pipelineConfig) throws Exception {
    PartialConfig partialConfig = new PartialConfig();
    partialConfig.getGroups().addPipeline(PipelineConfigs.DEFAULT_GROUP, pipelineConfig);
    return this.addFileWithPartialConfig(relativePath, partialConfig);
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig)

Example 53 with PartialConfig

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

the class XmlPartialConfigProviderTest method shouldParseFileWithOnePipelineGroup.

@Test
public void shouldParseFileWithOnePipelineGroup() throws Exception {
    GoConfigMother mother = new GoConfigMother();
    PipelineConfigs group1 = mother.cruiseConfigWithOnePipelineGroup().getGroups().get(0);
    File file = helper.addFileWithPipelineGroup("group1.gocd.xml", group1);
    PartialConfig part = xmlPartialProvider.parseFile(file);
    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) File(java.io.File) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.Test)

Example 54 with PartialConfig

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

the class XmlPartialConfigProviderTest method shouldLoadDirectoryWithTwoPipelineGroupsAndEnvironment.

@Test
public void shouldLoadDirectoryWithTwoPipelineGroupsAndEnvironment() throws Exception {
    GoConfigMother mother = new GoConfigMother();
    PipelineGroups groups = mother.cruiseConfigWithTwoPipelineGroups().getGroups();
    EnvironmentConfig env = EnvironmentConfigMother.environment("dev");
    helper.addFileWithPipelineGroup("group1.gocd.xml", groups.get(0));
    helper.addFileWithPipelineGroup("group2.gocd.xml", groups.get(1));
    helper.addFileWithEnvironment("dev-env.gocd.xml", env);
    PartialConfig part = xmlPartialProvider.load(tmpFolder, mock(PartialConfigLoadContext.class));
    PipelineGroups groupsRead = part.getGroups();
    assertThat(groupsRead.size(), is(2));
    EnvironmentsConfig loadedEnvs = part.getEnvironments();
    assertThat(loadedEnvs.size(), is(1));
    assertThat(loadedEnvs.get(0), is(env));
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.Test)

Example 55 with PartialConfig

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

the class XmlPartialConfigProviderTest method shouldFailToLoadDirectoryWithDuplicatedPipeline.

@Test
public void shouldFailToLoadDirectoryWithDuplicatedPipeline() throws Exception {
    GoConfigMother mother = new GoConfigMother();
    PipelineConfig pipe1 = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
    helper.addFileWithPipeline("pipe1.gocd.xml", pipe1);
    helper.addFileWithPipeline("pipedup.gocd.xml", pipe1);
    try {
        PartialConfig part = xmlPartialProvider.load(tmpFolder, mock(PartialConfigLoadContext.class));
    } catch (Exception ex) {
        assertThat(ex.getMessage(), is("You have defined multiple pipelines called 'pipeline1'. Pipeline names must be unique."));
        return;
    }
    fail("should have thrown");
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) IOException(java.io.IOException) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.Test)

Aggregations

PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)70 Test (org.junit.Test)39 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)29 File (java.io.File)15 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)12 StringContains.containsString (org.hamcrest.core.StringContains.containsString)12 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 PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)7 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)7 Cloner (com.rits.cloning.Cloner)6 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)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 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3