use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class GitMaterialTest method shouldDeleteAndRecheckoutDirectoryWhenUrlChanges.
@Test
public void shouldDeleteAndRecheckoutDirectoryWhenUrlChanges() throws Exception {
git.latestModification(workingDir, new TestSubprocessExecutionContext());
File shouldBeRemoved = new File(workingDir, "shouldBeRemoved");
shouldBeRemoved.createNewFile();
assertThat(shouldBeRemoved.exists(), is(true));
git = new GitMaterial(new GitTestRepo(temporaryFolder).projectRepositoryUrl());
git.latestModification(workingDir, new TestSubprocessExecutionContext());
assertThat("Should have deleted whole folder", shouldBeRemoved.exists(), is(false));
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class MaterialDatabaseUpdaterIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
dbHelper.onSetUp();
testRepo = new GitTestRepo(temporaryFolder);
MaterialService slowMaterialService = new MaterialServiceWhichSlowsDownFirstTimeModificationCheck(materialRepository, goConfigService, securityService, packageRepositoryExtension, scmExtension);
LegacyMaterialChecker materialChecker = new LegacyMaterialChecker(slowMaterialService, subprocessExecutionContext);
ScmMaterialUpdater scmMaterialUpdater = new ScmMaterialUpdater(materialRepository, materialChecker, subprocessExecutionContext, slowMaterialService);
transactionTemplateWithInvocationCount = new TransactionTemplateWithInvocationCount(transactionTemplate);
updater = new MaterialDatabaseUpdater(materialRepository, serverHealthService, transactionTemplateWithInvocationCount, dependencyMaterialUpdater, scmMaterialUpdater, packageMaterialUpdater, pluggableSCMMaterialUpdater, materialExpansionService);
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class MaterialDatabaseUpdaterIntegrationTest method setUp.
@BeforeEach
public void setUp(@TempDir Path tempDir) throws Exception {
dbHelper.onSetUp();
testRepo = new GitTestRepo(tempDir);
MaterialService slowMaterialService = new MaterialServiceWhichSlowsDownFirstTimeModificationCheck(materialRepository, goConfigService, securityService, packageRepositoryExtension, scmExtension);
LegacyMaterialChecker materialChecker = new LegacyMaterialChecker(slowMaterialService, subprocessExecutionContext);
ScmMaterialUpdater scmMaterialUpdater = new ScmMaterialUpdater(materialRepository, materialChecker, subprocessExecutionContext, slowMaterialService);
transactionTemplateWithInvocationCount = new TransactionTemplateWithInvocationCount(transactionTemplate);
updater = new MaterialDatabaseUpdater(materialRepository, serverHealthService, transactionTemplateWithInvocationCount, dependencyMaterialUpdater, scmMaterialUpdater, packageMaterialUpdater, pluggableSCMMaterialUpdater, materialExpansionService, goConfigService);
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class BuildCauseProducerServiceDependencyIntegrationTest method setup.
@BeforeEach
public void setup(@TempDir Path tempDir) throws Exception {
dbHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao);
configHelper.onSetUp();
dependencyMaterialUpdateNotifier.disableUpdates();
minglePipeline = new MinglePipeline();
goPipeline = new GoPipeline();
svnRepository = new SvnTestRepo(tempDir);
repository = new SvnCommand(null, svnRepository.projectRepositoryUrl());
svnMaterialRevs = new MaterialRevisions();
svnMaterial = new SvnMaterial(repository);
svnMaterialRevs.addRevision(svnMaterial, svnMaterial.latestModification(null, new ServerSubprocessExecutionContext(goConfigService, new SystemEnvironment())));
final MaterialRevisions materialRevisions = new MaterialRevisions();
SvnMaterial anotherSvnMaterial = new SvnMaterial(repository);
materialRevisions.addRevision(anotherSvnMaterial, anotherSvnMaterial.latestModification(null, subprocessExecutionContext));
gitTestRepo = new GitTestRepo(tempDir);
MaterialRevisions gitMaterialRevs = new MaterialRevisions();
gitMaterial = gitTestRepo.createMaterial();
gitMaterialRevs.addRevision(gitMaterial, gitTestRepo.latestModifications());
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
materialRepository.save(svnMaterialRevs);
materialRepository.save(gitMaterialRevs);
}
});
BuildCause buildCause = BuildCause.createWithModifications(svnMaterialRevs, "");
minglePipeline.setup(buildCause);
goPipeline.setup(buildCause);
result = new HttpOperationResult();
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered.
@Test
public void shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered(@TempDir Path tempDir) throws Exception {
GitTestRepo otherGitRepo = new GitTestRepo(tempDir);
pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
pipelineConfig.materialConfigs().clear();
materialConfig = hgRepo.createMaterialConfig("dest1");
materialConfig.setAutoUpdate(true);
pipelineConfig.materialConfigs().add(materialConfig);
// new material is added
GitMaterial gitMaterial = otherGitRepo.createMaterial("dest2");
gitMaterial.setAutoUpdate(true);
MaterialConfig otherMaterialConfig = gitMaterial.config();
otherMaterialConfig.setAutoUpdate(true);
pipelineConfig.materialConfigs().add(otherMaterialConfig);
List<Modification> mod = configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
final HashMap<String, String> revisions = new HashMap<>();
final HashMap<String, String> environmentVariables = new HashMap<>();
buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
cachedGoConfig.throwExceptionIfExists();
Map<CaseInsensitiveString, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(20);
assertThat(afterLoad.keySet(), hasItem(new CaseInsensitiveString(PIPELINE_NAME)));
BuildCause cause = afterLoad.get(new CaseInsensitiveString(PIPELINE_NAME));
assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
PipelineConfig pipelineConfigAfterSchedule = goConfigService.pipelineConfigNamed(pipelineConfig.name());
RepoConfigOrigin configOriginAfterSchedule = (RepoConfigOrigin) pipelineConfigAfterSchedule.getOrigin();
String lastPushedRevision = mod.get(0).getRevision();
assertThat("revisionOfPipelineConfigOriginShouldMatchLastPushedCommit", configOriginAfterSchedule.getRevision(), is(lastPushedRevision));
assertThat(pipelineConfig.materialConfigs(), hasItem(otherMaterialConfig));
assertThat("buildCauseRevisionShouldMatchLastPushedCommit", cause.getMaterialRevisions().latestRevision(), is(lastPushedRevision));
// update of commited material happened during manual trigger
MaterialRevisions modificationsInDb = materialRepository.findLatestModification(gitMaterial);
assertThat(modificationsInDb.latestRevision(), is(otherGitRepo.latestModification().get(0).getRevision()));
}
Aggregations