use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.
the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemoteAgents.
@Test
public void shouldNotAllowRemovingRemoteAgents() throws Exception {
String agentUUID = "remote-agent-to-remove";
BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
local.setOrigins(new FileConfigOrigin());
BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
remote.addAgent(agentUUID);
ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
agentsToRemove.add(agentUUID);
PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
assertFalse(cruiseConfig.getEnvironments().find(environmentName).containsPipeline(new CaseInsensitiveString(agentUUID)));
command.update(cruiseConfig);
// preprocess
cruiseConfig.getEnvironments().replace(cruiseConfig.getEnvironments().find(environmentName), mergedConfig);
boolean isValid = command.isValid(cruiseConfig);
assertFalse(isValid);
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
String message = "Agent with uuid 'remote-agent-to-remove' cannot be removed from environment 'Dev' as the association has been defined remotely in [foo/bar.git at latest]";
expectedResult.unprocessableEntity(actionFailed.addParam(message));
assertThat(result, is(expectedResult));
}
use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.
the class BasicPipelineConfigsTest method shouldReturnSelfForGetLocalPartsWhenOriginIsFile.
@Test
public void shouldReturnSelfForGetLocalPartsWhenOriginIsFile() {
PipelineConfigs pipelineConfigs = createEmpty();
pipelineConfigs.setOrigins(new FileConfigOrigin());
assertThat(pipelineConfigs.getLocal().size(), is(0));
assertSame(pipelineConfigs, pipelineConfigs.getLocal());
}
use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.
the class PipelineConfigTest method shouldReturnFalseIfOneOfPipelineMaterialsIsTheSameAsConfigOrigin_WhenOriginIsFile.
@Test
public void shouldReturnFalseIfOneOfPipelineMaterialsIsTheSameAsConfigOrigin_WhenOriginIsFile() {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline", "stage", "build");
pipelineConfig.setOrigin(new FileConfigOrigin());
assertThat(pipelineConfig.isConfigOriginSameAsOneOfMaterials(), is(false));
}
use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.
the class EnvironmentsConfigTest method shouldGetLocalPartsWhenOriginIsMixed.
@Test
public void shouldGetLocalPartsWhenOriginIsMixed() {
env.setOrigins(new FileConfigOrigin());
BasicEnvironmentConfig prodLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("PROD"));
prodLocalPart.addAgent("1235");
prodLocalPart.setOrigins(new FileConfigOrigin());
BasicEnvironmentConfig prodRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("PROD"));
prodRemotePart.setOrigins(new RepoConfigOrigin());
MergeEnvironmentConfig pairEnvironmentConfig = new MergeEnvironmentConfig(prodLocalPart, prodRemotePart);
configs.add(pairEnvironmentConfig);
assertThat(configs.getLocal().size(), is(2));
assertThat(configs.getLocal(), hasItem(env));
assertThat(configs.getLocal(), hasItem(prodLocalPart));
}
use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.
the class EnvironmentsConfigTest method shouldGetLocalPartsWhenOriginIsFile.
@Test
public void shouldGetLocalPartsWhenOriginIsFile() {
env.setOrigins(new FileConfigOrigin());
assertThat(configs.getLocal().size(), is(1));
assertThat(configs.getLocal().get(0), Is.<EnvironmentConfig>is(env));
}
Aggregations