Search in sources :

Example 16 with RepoConfigOrigin

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

the class MergeEnvironmentConfigTest method shouldUpdateEnvironmentVariablesWhenSourceIsEditable.

@Test
public void shouldUpdateEnvironmentVariablesWhenSourceIsEditable() {
    BasicEnvironmentConfig uatLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    uatLocalPart.addEnvironmentVariable("hello", "world");
    environmentConfig = new MergeEnvironmentConfig(uatLocalPart, uatRemotePart);
    environmentConfig.setConfigAttributes(new SingletonMap(BasicEnvironmentConfig.VARIABLES_FIELD, Arrays.asList(envVar("foo", "bar"), envVar("baz", "quux"), envVar("hello", "you"))));
    assertThat(environmentConfig.getVariables(), hasItem(new EnvironmentVariableConfig("hello", "you")));
    assertThat(environmentConfig.getVariables(), hasItem(new EnvironmentVariableConfig("foo", "bar")));
    assertThat(environmentConfig.getVariables(), hasItem(new EnvironmentVariableConfig("baz", "quux")));
    assertThat(environmentConfig.getVariables().size(), is(3));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables(), hasItem(new EnvironmentVariableConfig("hello", "you")));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables(), hasItem(new EnvironmentVariableConfig("foo", "bar")));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables(), hasItem(new EnvironmentVariableConfig("baz", "quux")));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables().size(), is(3));
}
Also used : SingletonMap(org.apache.commons.collections.map.SingletonMap) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 17 with RepoConfigOrigin

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

the class MergeEnvironmentConfigTest method shouldReturnFalseWhenPartIsRemote.

@Test
public void shouldReturnFalseWhenPartIsRemote() {
    BasicEnvironmentConfig uatLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    environmentConfig = new MergeEnvironmentConfig(uatLocalPart, uatRemotePart);
    assertThat(environmentConfig.isLocal(), is(false));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 18 with RepoConfigOrigin

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

the class MergeEnvironmentConfigTest method setUp.

@Before
public void setUp() throws Exception {
    localUatEnv1 = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    localUatEnv1.setOrigins(new FileConfigOrigin());
    singleEnvironmentConfig = new MergeEnvironmentConfig(localUatEnv1);
    uatLocalPart2 = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart2.setOrigins(new FileConfigOrigin());
    uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    pairEnvironmentConfig = new MergeEnvironmentConfig(uatLocalPart2, uatRemotePart);
    super.environmentConfig = pairEnvironmentConfig;
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Before(org.junit.Before)

Example 19 with RepoConfigOrigin

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

the class MergeEnvironmentConfigTest method shouldReturnCorrectOriginOfDefinedAgent.

@Test
public void shouldReturnCorrectOriginOfDefinedAgent() throws Exception {
    BasicEnvironmentConfig uatLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart.setOrigins(new FileConfigOrigin());
    String localAgent = "local-agent";
    uatLocalPart.addAgent(localAgent);
    BasicEnvironmentConfig uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    String remoteAgent = "remote-agent";
    uatRemotePart.addAgent(remoteAgent);
    MergeEnvironmentConfig environmentConfig = new MergeEnvironmentConfig(uatLocalPart, uatRemotePart);
    assertThat(environmentConfig.getOriginForAgent(localAgent), is(new FileConfigOrigin()));
    assertThat(environmentConfig.getOriginForAgent(remoteAgent), is(new RepoConfigOrigin()));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 20 with RepoConfigOrigin

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

the class MergeOriginConfigTest method shouldShowDisplayName.

@Test
public void shouldShowDisplayName() {
    FileConfigOrigin fileConfigOrigin = new FileConfigOrigin();
    RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(new ConfigRepoConfig(new SvnMaterialConfig("http://mysvn", false), "myplugin"), "123");
    MergeConfigOrigin mergeOrigin = new MergeConfigOrigin(fileConfigOrigin, repoConfigOrigin);
    assertThat(mergeOrigin.displayName(), is("Merged: [ cruise-config.xml; http://mysvn at 123; ]"));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

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