Search in sources :

Example 11 with HgTestRepo

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

the class HgMaterialUpdaterTest method shouldNotDeleteAndRecheckoutDirectoryUnlessUrlChanges.

@Test
public void shouldNotDeleteAndRecheckoutDirectoryUnlessUrlChanges() throws Exception {
    String repositoryUrl = new HgTestRepo(temporaryFolder).projectRepositoryUrl();
    HgMaterial material = MaterialsMother.hgMaterial(repositoryUrl);
    updateTo(material, new RevisionContext(REVISION_0), JobResult.Passed);
    File shouldNotBeRemoved = new File(workingFolder, "shouldBeRemoved");
    shouldNotBeRemoved.createNewFile();
    assertThat(shouldNotBeRemoved.exists(), is(true));
    updateTo(material, new RevisionContext(REVISION_2), JobResult.Passed);
    assert (MaterialUrl.sameUrl(material.getUrl(), repositoryUrl));
    assertThat(shouldNotBeRemoved.exists(), is(true));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringContains.containsString(org.hamcrest.core.StringContains.containsString) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) File(java.io.File) Test(org.junit.Test)

Example 12 with HgTestRepo

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

the class BuildCauseProducerServiceConfigRepoIntegrationTest method setup.

@Before
public void setup() throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    hgRepo = new HgTestRepo("testHgRepo", temporaryFolder);
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    materialConfig = hgRepo.materialConfig();
    configHelper.addConfigRepo(new ConfigRepoConfig(materialConfig, "gocd-xml"));
    logger = mock(MDUPerformanceLogger.class);
    TestingEmailSender emailSender = new TestingEmailSender();
    SystemDiskSpaceChecker mockDiskSpaceChecker = Mockito.mock(SystemDiskSpaceChecker.class);
    StageService stageService = mock(StageService.class);
    ConfigDbStateRepository configDbStateRepository = mock(ConfigDbStateRepository.class);
    goDiskSpaceMonitor = new GoDiskSpaceMonitor(goConfigService, systemEnvironment, serverHealthService, emailSender, mockDiskSpaceChecker, mock(ArtifactsService.class), stageService, configDbStateRepository);
    goDiskSpaceMonitor.initialize();
    worker = new MaterialUpdateListener(configTopic, materialDatabaseUpdater, logger, goDiskSpaceMonitor);
    xmlWriter = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins());
    configTestRepo = new ConfigTestRepo(hgRepo, xmlWriter);
    this.material = (HgMaterial) materialConfigConverter.toMaterial(materialConfig);
    pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
    pipelineConfig.materialConfigs().clear();
    pipelineConfig.materialConfigs().add(materialConfig);
    PIPELINE_NAME = CaseInsensitiveString.str(pipelineConfig.name());
    configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
    materialUpdateService.updateMaterial(material);
    // time for messages to pass through all services
    waitForMaterialNotInProgress();
    pipelineConfig = goConfigService.pipelineConfigNamed(pipelineConfig.name());
    pipelineScheduleQueue.clear();
    // check test setup
    Materials materials = materialConfigConverter.toMaterials(pipelineConfig.materialConfigs());
    MaterialRevisions peggedRevisions = new MaterialRevisions();
    firstRevisions = materialChecker.findLatestRevisions(peggedRevisions, materials);
    assertThat(firstRevisions.isMissingModifications(), is(false));
}
Also used : MDUPerformanceLogger(com.thoughtworks.go.server.perf.MDUPerformanceLogger) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) GoDiskSpaceMonitor(com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) ConfigTestRepo(com.thoughtworks.go.helper.ConfigTestRepo) Before(org.junit.Before)

Example 13 with HgTestRepo

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

the class ConfigMaterialUpdaterIntegrationTest method setup.

@Before
public void setup() throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    hgRepo = new HgTestRepo("testHgRepo", temporaryFolder);
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    materialConfig = new HgMaterialConfig(hgRepo.projectRepositoryUrl(), null);
    configHelper.addConfigRepo(new ConfigRepoConfig(materialConfig, "gocd-xml"));
    logger = mock(MDUPerformanceLogger.class);
    TestingEmailSender emailSender = new TestingEmailSender();
    SystemDiskSpaceChecker mockDiskSpaceChecker = Mockito.mock(SystemDiskSpaceChecker.class);
    StageService stageService = mock(StageService.class);
    ConfigDbStateRepository configDbStateRepository = mock(ConfigDbStateRepository.class);
    GoDiskSpaceMonitor goDiskSpaceMonitor = new GoDiskSpaceMonitor(goConfigService, systemEnvironment, serverHealthService, emailSender, mockDiskSpaceChecker, mock(ArtifactsService.class), stageService, configDbStateRepository);
    goDiskSpaceMonitor.initialize();
    worker = new MaterialUpdateListener(configTopic, materialDatabaseUpdater, logger, goDiskSpaceMonitor);
    xmlWriter = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins());
    configTestRepo = new ConfigTestRepo(hgRepo, xmlWriter);
    this.material = configTestRepo.getMaterial();
}
Also used : MDUPerformanceLogger(com.thoughtworks.go.server.perf.MDUPerformanceLogger) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) GoDiskSpaceMonitor(com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) ConfigTestRepo(com.thoughtworks.go.helper.ConfigTestRepo)

Aggregations

HgTestRepo (com.thoughtworks.go.helper.HgTestRepo)13 Before (org.junit.Before)7 SvnTestRepo (com.thoughtworks.go.helper.SvnTestRepo)3 File (java.io.File)3 StringContains.containsString (org.hamcrest.core.StringContains.containsString)3 Test (org.junit.Test)3 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)2 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)2 ConfigTestRepo (com.thoughtworks.go.helper.ConfigTestRepo)2 GoDiskSpaceMonitor (com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor)2 MDUPerformanceLogger (com.thoughtworks.go.server.perf.MDUPerformanceLogger)2 GoConfigFileHelper (com.thoughtworks.go.util.GoConfigFileHelper)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 Filter (com.thoughtworks.go.config.materials.Filter)1 IgnoredFiles (com.thoughtworks.go.config.materials.IgnoredFiles)1 Materials (com.thoughtworks.go.config.materials.Materials)1 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)1 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)1