Search in sources :

Example 16 with MergeEnvironmentConfig

use of com.thoughtworks.go.config.merge.MergeEnvironmentConfig in project gocd by gocd.

the class EnvironmentConfigServiceTest method shouldGetEditablePartOfEnvironmentConfig.

@Test
void shouldGetEditablePartOfEnvironmentConfig() {
    String uat = "uat";
    BasicEnvironmentConfig local = new BasicEnvironmentConfig(new CaseInsensitiveString("uat"));
    local.addEnvironmentVariable("user", "admin");
    BasicEnvironmentConfig remote = new BasicEnvironmentConfig(new CaseInsensitiveString("uat"));
    remote.addEnvironmentVariable("foo", "bar");
    MergeEnvironmentConfig merged = new MergeEnvironmentConfig(local, remote);
    EnvironmentsConfig environments = new EnvironmentsConfig();
    environments.add(merged);
    environmentConfigService.syncEnvironments(environments);
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    BasicEnvironmentConfig env = (BasicEnvironmentConfig) environmentConfigService.getEnvironmentConfig(uat).getLocal();
    cruiseConfig.addEnvironment(env);
    BasicEnvironmentConfig expectedToEdit = GoConfigMother.deepClone(env);
    when(mockGoConfigService.getConfigForEditing()).thenReturn(cruiseConfig);
    assertThat(environmentConfigService.getEnvironmentForEdit(uat), is(expectedToEdit));
}
Also used : MergeEnvironmentConfig(com.thoughtworks.go.config.merge.MergeEnvironmentConfig) Test(org.junit.jupiter.api.Test)

Aggregations

MergeEnvironmentConfig (com.thoughtworks.go.config.merge.MergeEnvironmentConfig)16 Test (org.junit.jupiter.api.Test)10 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)4 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)4 Test (org.junit.Test)4 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 EnvironmentConfig (com.thoughtworks.go.config.EnvironmentConfig)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)2 BasicEnvironmentConfig (com.thoughtworks.go.config.BasicEnvironmentConfig)1 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1 AgentInstances (com.thoughtworks.go.server.domain.AgentInstances)1 DisplayName (org.junit.jupiter.api.DisplayName)1