use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision.
@Test
public void shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision() {
PipelineConfig pipelineConfig = fixture.pipelineConfig();
BuildCause cause = modifySomeFilesAndTriggerAs(pipelineConfig, "cruise-developer");
MaterialConfig materialConfig = pipelineConfig.materialConfigs().first();
cause.getMaterialRevisions().findRevisionFor(materialConfig);
pipelineConfig.setOrigins(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig, "123"), "plug"));
saveRev(cause);
queue.schedule(fixture.pipelineName, cause);
Pipeline pipeline = queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
assertThat(pipeline, is(nullValue()));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig 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.ConfigRepoConfig in project gocd by gocd.
the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemoteEnvironmentVariables.
@Test
public void shouldNotAllowRemovingRemoteEnvironmentVariables() throws Exception {
String variableName = "remote-env-var-to-remove";
BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
local.setOrigins(new FileConfigOrigin());
BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
remote.addEnvironmentVariable(variableName, "bar");
ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
envVarsToRemove.add(variableName);
PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
assertFalse(cruiseConfig.getEnvironments().find(environmentName).getVariables().hasVariable(variableName));
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 = "Environment variable with name 'remote-env-var-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.ConfigRepoConfig in project gocd by gocd.
the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemotePipeline.
@Test
public void shouldNotAllowRemovingRemotePipeline() throws Exception {
CaseInsensitiveString pipelineName = new CaseInsensitiveString("remote-pipeline-to-remove");
BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
local.setOrigins(new FileConfigOrigin());
BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
remote.addPipeline(pipelineName);
ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
pipelinesToRemove.add(pipelineName.toString());
PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
assertFalse(cruiseConfig.getEnvironments().find(environmentName).containsPipeline(new CaseInsensitiveString(pipelineName.toString())));
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 = "Pipeline 'remote-pipeline-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.ConfigRepoConfig in project gocd by gocd.
the class GoConfigWatchListTest method shouldReturnConfigRepoForMaterial.
@Test
public void shouldReturnConfigRepoForMaterial() {
GitMaterialConfig gitrepo = new GitMaterialConfig("http://configrepo.git");
ConfigRepoConfig repoConfig = new ConfigRepoConfig(gitrepo, "myplugin");
when(cruiseConfig.getConfigRepos()).thenReturn(new ConfigReposConfig(repoConfig));
watchList = new GoConfigWatchList(cachedGoConfig);
assertThat(watchList.getConfigRepoForMaterial(gitrepo), is(repoConfig));
}
Aggregations