Exemple #1
0
 @Test
 public void shouldReturnAClonedInstanceOfEnvironmentConfig() throws NoSuchEnvironmentException {
   HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
   configHelper.addEnvironments("foo-env");
   assertThat(service.named("foo-env"), sameInstance(service.named("foo-env")));
   assertThat(
       service.named("foo-env"),
       not(sameInstance(service.forEdit("foo-env", result).getConfigElement())));
   assertThat(result.isSuccessful(), is(true));
 }
Exemple #2
0
 @Test
 public void shouldUpdateExistingEnvironment() throws Exception {
   BasicEnvironmentConfig uat = environmentConfig("uat");
   goConfigService.addPipeline(
       PipelineConfigMother.createPipelineConfig("foo", "dev", "job"), "foo-grp");
   goConfigService.addPipeline(
       PipelineConfigMother.createPipelineConfig("bar", "dev", "job"), "foo-grp");
   Username user = Username.ANONYMOUS;
   agentConfigService.addAgent(new AgentConfig("uuid-1", "host-1", "192.168.1.2"), user);
   agentConfigService.addAgent(new AgentConfig("uuid-2", "host-2", "192.168.1.3"), user);
   uat.addPipeline(new CaseInsensitiveString("foo"));
   uat.addAgent("uuid-2");
   uat.addEnvironmentVariable("env-one", "ONE");
   uat.addEnvironmentVariable("env-two", "TWO");
   goConfigService.addEnvironment(new BasicEnvironmentConfig(new CaseInsensitiveString("dev")));
   goConfigService.addEnvironment(new BasicEnvironmentConfig(new CaseInsensitiveString("qa")));
   goConfigService.addEnvironment(uat);
   goConfigService.addEnvironment(
       new BasicEnvironmentConfig(new CaseInsensitiveString("acceptance")));
   goConfigService.addEnvironment(
       new BasicEnvironmentConfig(new CaseInsensitiveString("function_testing")));
   EnvironmentConfig newUat = new BasicEnvironmentConfig(new CaseInsensitiveString("prod"));
   newUat.addPipeline(new CaseInsensitiveString("bar"));
   newUat.addAgent("uuid-1");
   newUat.addEnvironmentVariable("env-three", "THREE");
   HttpLocalizedOperationResult result =
       service.updateEnvironment(
           "uat",
           newUat,
           new Username(new CaseInsensitiveString("foo")),
           goConfigDao.md5OfConfigFile());
   EnvironmentConfig updatedEnv = service.named("prod");
   assertThat(updatedEnv.name(), is(new CaseInsensitiveString("prod")));
   assertThat(updatedEnv.getAgents().getUuids(), is(Arrays.asList("uuid-1")));
   assertThat(updatedEnv.getPipelineNames(), is(Arrays.asList(new CaseInsensitiveString("bar"))));
   EnvironmentVariablesConfig updatedVariables = new EnvironmentVariablesConfig();
   updatedVariables.add("env-three", "THREE");
   assertThat(updatedEnv.getVariables(), is(updatedVariables));
   EnvironmentsConfig currentEnvironments = goConfigService.getCurrentConfig().getEnvironments();
   assertThat(currentEnvironments.indexOf(updatedEnv), is(2));
   assertThat(currentEnvironments.size(), is(5));
 }