use of com.thoughtworks.go.config.BasicEnvironmentConfig in project gocd by gocd.
the class EnvironmentsConfigTest method shouldRemoveAgentFromAllEnvironments.
@Test
public void shouldRemoveAgentFromAllEnvironments() throws Exception {
BasicEnvironmentConfig env2 = new BasicEnvironmentConfig(new CaseInsensitiveString("prod"));
env2.addPipeline(new CaseInsensitiveString("test"));
env2.addAgent("agent-one");
env2.addAgent("agent-two");
configs.add(env2);
BasicEnvironmentConfig env3 = new BasicEnvironmentConfig(new CaseInsensitiveString("dev"));
env3.addPipeline(new CaseInsensitiveString("build"));
env3.addAgent("agent-two");
env3.addAgent("agent-three");
configs.add(env3);
assertThat(configs.get(0).getAgents().size(), is(1));
assertThat(configs.get(1).getAgents().size(), is(2));
assertThat(configs.environmentsForAgent("agent-one").size(), is(2));
configs.removeAgentFromAllEnvironments("agent-one");
assertThat(configs.get(0).getAgents().size(), is(0));
assertThat(configs.get(1).getAgents().size(), is(1));
assertThat(configs.get(2).getAgents().size(), is(2));
assertThat(configs.environmentsForAgent("agent-one").size(), is(0));
assertThat(configs.environmentsForAgent("agent-two").size(), is(2));
assertThat(configs.environmentsForAgent("agent-three").size(), is(1));
}
use of com.thoughtworks.go.config.BasicEnvironmentConfig 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.BasicEnvironmentConfig in project gocd by gocd.
the class EnvironmentConfigMother method environment.
public static BasicEnvironmentConfig environment(String name) {
BasicEnvironmentConfig uat = new BasicEnvironmentConfig(new CaseInsensitiveString(name));
uat.addPipeline(new CaseInsensitiveString(name + "-pipeline"));
uat.addAgent(name + "-agent");
uat.addAgent(OMNIPRESENT_AGENT);
return uat;
}
use of com.thoughtworks.go.config.BasicEnvironmentConfig in project gocd by gocd.
the class AddEnvironmentCommandTest method setup.
@Before
public void setup() throws Exception {
initMocks(this);
currentUser = new Username(new CaseInsensitiveString("user"));
cruiseConfig = new GoConfigMother().defaultCruiseConfig();
environmentName = new CaseInsensitiveString("Dev");
environmentConfig = new BasicEnvironmentConfig(environmentName);
result = new HttpLocalizedOperationResult();
actionFailed = LocalizedMessage.string("ENV_ADD_FAILED");
}
use of com.thoughtworks.go.config.BasicEnvironmentConfig in project gocd by gocd.
the class DeleteEnvironmentCommandTest method setup.
@Before
public void setup() throws Exception {
initMocks(this);
currentUser = new Username(new CaseInsensitiveString("user"));
cruiseConfig = new GoConfigMother().defaultCruiseConfig();
environmentName = new CaseInsensitiveString("Dev");
environmentConfig = new BasicEnvironmentConfig(environmentName);
result = new HttpLocalizedOperationResult();
cruiseConfig.addEnvironment(environmentConfig);
actionFailed = LocalizedMessage.string("ENV_DELETE_FAILED", environmentName);
}
Aggregations