Search in sources :

Example 96 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class ConfigRepoConfigTest method validate_shouldNotAllowDisabledAutoUpdate.

@Test
public void validate_shouldNotAllowDisabledAutoUpdate() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    GoConfigMother mother = new GoConfigMother();
    SvnMaterialConfig svn = new SvnMaterialConfig("url", false);
    svn.setAutoUpdate(false);
    ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(svn, "plug");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
    configRepoConfig.validate(null);
    assertThat(configRepoConfig.errors().isEmpty(), is(false));
    assertThat(configRepoConfig.errors().on(ConfigRepoConfig.AUTO_UPDATE), is("Configuration repository material url must have autoUpdate enabled"));
}
Also used : SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.Test)

Example 97 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class ConfigRepoConfigTest method validate_shouldNotAllowPipelineWithSameRepositoryAndDisabledAutoUpdate.

@Test
public void validate_shouldNotAllowPipelineWithSameRepositoryAndDisabledAutoUpdate() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    GoConfigMother mother = new GoConfigMother();
    MaterialConfigs materialConfigs = new MaterialConfigs();
    SvnMaterialConfig svn = new SvnMaterialConfig("url", false);
    svn.setAutoUpdate(false);
    materialConfigs.add(svn);
    ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(svn, "plug");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
    PipelineConfig pipeline1 = mother.addPipeline(cruiseConfig, "badpipe", "build", materialConfigs, "build");
    configRepoConfig.validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
    assertThat(svn.errors().isEmpty(), is(false));
    assertThat(svn.errors().on(ScmMaterialConfig.AUTO_UPDATE), is("Material of type Subversion (url) is specified as a configuration repository and pipeline material with disabled autoUpdate. All copies of this material must have autoUpdate enabled or configuration repository must be removed"));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.Test)

Example 98 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class AgentsEntityConfigUpdateCommandTest method setUp.

@Before
public void setUp() throws Exception {
    result = new HttpLocalizedOperationResult();
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    goConfigService = mock(GoConfigService.class);
    agentInstances = mock(AgentInstances.class);
    uuids = new ArrayList<>();
    environmentsToAdd = new ArrayList<>();
    environmentsToRemove = new ArrayList<>();
    resourcesToAdd = new ArrayList<>();
    resourcesToRemove = new ArrayList<>();
    triState = TriState.TRUE;
    when(goConfigService.getEnvironments()).thenReturn(cruiseConfig.getEnvironments());
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) AgentInstances(com.thoughtworks.go.server.domain.AgentInstances) Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Example 99 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class ConfigMaterialUpdaterIntegrationTest method shouldParseAndLoadValidPartialConfig.

@Test
public void shouldParseAndLoadValidPartialConfig() throws Exception {
    String fileName = "pipe1.gocd.xml";
    GoConfigMother mother = new GoConfigMother();
    PipelineConfig pipelineConfig = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
    configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
    materialUpdateService.updateMaterial(material);
    // time for messages to pass through all services
    waitForMaterialNotInProgress();
    PartialConfig partial = goRepoConfigDataSource.latestPartialConfigForMaterial(materialConfig);
    assertNotNull(partial);
    assertThat(partial.getGroups().get(0).size(), is(1));
    assertThat(partial.getGroups().get(0).get(0), is(pipelineConfig));
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother)

Example 100 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class ConfigMaterialUpdaterIntegrationTest method shouldCheckoutNewMaterial.

@Test
public void shouldCheckoutNewMaterial() throws Exception {
    GoConfigMother mother = new GoConfigMother();
    PipelineConfig pipelineConfig = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
    configTestRepo.addPipelineToRepositoryAndPush("pipe1.gocd.xml", pipelineConfig);
    materialUpdateService.updateMaterial(material);
    // time for messages to pass through all services
    waitForMaterialNotInProgress();
    File flyweightDir = materialRepository.folderFor(material);
    Assert.assertThat(flyweightDir.exists(), is(true));
    Assert.assertThat(new File(flyweightDir, "pipe1.gocd.xml").exists(), is(true));
}
Also used : File(java.io.File) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother)

Aggregations

GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)102 Test (org.junit.jupiter.api.Test)64 Username (com.thoughtworks.go.server.domain.Username)30 BeforeEach (org.junit.jupiter.api.BeforeEach)19 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)13 GoConfigValidity (com.thoughtworks.go.config.validation.GoConfigValidity)12 File (java.io.File)9 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)8 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 SCM (com.thoughtworks.go.domain.scm.SCM)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)3 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)3 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)3 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)3 Configuration (com.thoughtworks.go.domain.config.Configuration)3 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)3