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));
}
Aggregations