use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class CcTrayBreakersCalculatorTest method shouldCaptureAuthorNamesOfUnchangedRevisionsIfThereAreNoChangedRevisions.
@Test
public void shouldCaptureAuthorNamesOfUnchangedRevisionsIfThereAreNoChangedRevisions() throws Exception {
Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
Modification user2Commit = ModificationsMother.checkinWithComment("124", "comment 2", "user2", "user2@domain2.com", new Date(), "bar.c");
MaterialRevision firstUnchangedRevision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit, user2Commit);
Modification user3Commit = ModificationsMother.checkinWithComment("125", "comment 1", "user3", "user3@domain2.com", new Date(), "bar.c");
MaterialRevision secondUnchangedRevision = new MaterialRevision(MaterialsMother.gitMaterial("bar.com"), user3Commit);
MaterialRevisions revisions = new MaterialRevisions(firstUnchangedRevision, secondUnchangedRevision);
when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(revisions);
CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
Set<String> actualBreakers = status.calculateFor(failedStage());
assertThat(actualBreakers, is(s("user1", "user2", "user3")));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class CcTrayBreakersCalculatorTest method shouldNotHaveAnyBreakersIfStageHasNotFailed.
@Test
public void shouldNotHaveAnyBreakersIfStageHasNotFailed() throws Exception {
Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
MaterialRevision revision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit);
revision.markAsChanged();
MaterialRevisions revisions = new MaterialRevisions(revision);
when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(revisions);
CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
Set<String> actualBreakers = status.calculateFor(StageMother.createPassedStage("pipeline1", 1, "stage1", 1, "job1", new Date()));
assertThat(actualBreakers, is(Collections.<String>emptySet()));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class SCMRevisionTest method shouldRenderUsernameForDisplay.
@Test
public void shouldRenderUsernameForDisplay() throws Exception {
Modification modification = new Modification(null, "comment", "email", new Date(), "r1");
SCMRevision scmRevision = new SCMRevision(modification);
Assert.assertThat(scmRevision.getUser(), is(modification.getUserDisplayName()));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class BackupServiceIntegrationTest method shouldBackupConfigRepository.
@Test
public void shouldBackupConfigRepository() throws IOException {
configHelper.addPipeline("too-unique-to-be-present", "stage-name");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
backupService.startBackup(admin, result);
assertThat(result.isSuccessful(), is(true));
assertThat(result.message(localizer), is("Backup completed successfully."));
File repoZip = backedUpFile("config-repo.zip");
File repoDir = temporaryFolder.newFolder("expanded-config-repo-backup");
TestUtils.extractZipToDir(repoZip, repoDir);
File cloneDir = temporaryFolder.newFolder("cloned-config-repo-backup");
GitMaterial git = new GitMaterial(repoDir.getAbsolutePath());
List<Modification> modifications = git.latestModification(cloneDir, subprocessExecutionContext);
String latestChangeRev = modifications.get(0).getRevision();
git.checkout(cloneDir, new StringRevision(latestChangeRev), subprocessExecutionContext);
assertThat(FileUtils.readFileToString(new File(cloneDir, "cruise-config.xml"), UTF_8).indexOf("too-unique-to-be-present"), greaterThan(0));
StringRevision revision = new StringRevision(latestChangeRev + "~1");
git.updateTo(new InMemoryStreamConsumer(), cloneDir, new RevisionContext(revision), subprocessExecutionContext);
assertThat(FileUtils.readFileToString(new File(cloneDir, "cruise-config.xml"), UTF_8).indexOf("too-unique-to-be-present"), is(-1));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered.
@Test
public void shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered() throws Exception {
GitTestRepo otherGitRepo = new GitTestRepo(temporaryFolder);
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<String, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(20);
assertThat(afterLoad.keySet(), hasItem(PIPELINE_NAME));
BuildCause cause = afterLoad.get(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