use of com.thoughtworks.go.config.remote.FileConfigOrigin 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));
}
use of com.thoughtworks.go.config.remote.FileConfigOrigin 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));
}
use of com.thoughtworks.go.config.remote.FileConfigOrigin 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;
}
use of com.thoughtworks.go.config.remote.FileConfigOrigin 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()));
}
use of com.thoughtworks.go.config.remote.FileConfigOrigin 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; ]"));
}
Aggregations