use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class MaterialRevisionsTest method shouldReturnLatestChangeSetForDependencyMaterial.
@Test
public void shouldReturnLatestChangeSetForDependencyMaterial() {
Materials materials = new Materials(MaterialsMother.dependencyMaterial());
MaterialRevisions original = modifyOneFile(materials, "1");
MaterialRevisions newRevisions = modifyOneFile(materials, "2");
assertThat(newRevisions.hasChangedSince(original), is(true));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class GitMaterialTest method shouldUpdateSubmodules.
@Test
public void shouldUpdateSubmodules() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
File serverWorkingDir = temporaryFolder.newFolder();
Materials materials = new Materials();
materials.add(gitMaterial);
MaterialRevisions materialRevisions = materials.latestModification(serverWorkingDir, new TestSubprocessExecutionContext());
File agentWorkingDir = temporaryFolder.newFolder();
MaterialRevision materialRevision = materialRevisions.getMaterialRevision(0);
materialRevision.updateTo(agentWorkingDir, inMemoryConsumer(), new TestSubprocessExecutionContext());
File localFile = submoduleRepos.files(GitSubmoduleRepos.NAME).get(0);
assertThat(new File(agentWorkingDir, localFile.getName()), exists());
File file = submoduleRepos.files(SUBMODULE).get(0);
File workingSubmoduleFolder = new File(agentWorkingDir, "sub1");
assertThat(new File(workingSubmoduleFolder, file.getName()), exists());
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class GitMaterialTest method shouldGetLatestModificationsFromRepoWithSubmodules.
@Test
public void shouldGetLatestModificationsFromRepoWithSubmodules() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
File workingDirectory = temporaryFolder.newFolder();
Materials materials = new Materials();
materials.add(gitMaterial);
MaterialRevisions materialRevisions = materials.latestModification(workingDirectory, new TestSubprocessExecutionContext());
assertThat(materialRevisions.numberOfRevisions(), is(1));
MaterialRevision materialRevision = materialRevisions.getMaterialRevision(0);
assertThat(materialRevision.getRevision().getRevision(), is(submoduleRepos.currentRevision(GitSubmoduleRepos.NAME)));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class PipelineMother method pipelineWithAllTypesOfMaterials.
public static Pipeline pipelineWithAllTypesOfMaterials(String pipelineName, String stageName, String jobName, String fixedMaterialRevisionForAllMaterials) {
GitMaterial gitMaterial = MaterialsMother.gitMaterial("http://user:password@gitrepo.com", null, "branch");
HgMaterial hgMaterial = MaterialsMother.hgMaterial("http://user:password@hgrepo.com");
SvnMaterial svnMaterial = MaterialsMother.svnMaterial("http://user:password@svnrepo.com", null, "username", "password", false, null);
TfsMaterial tfsMaterial = MaterialsMother.tfsMaterial("http://user:password@tfsrepo.com");
P4Material p4Material = MaterialsMother.p4Material("127.0.0.1:1666", "username", "password", "view", false);
DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial();
PackageMaterial packageMaterial = MaterialsMother.packageMaterial();
PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
Materials materials = new Materials(gitMaterial, hgMaterial, svnMaterial, tfsMaterial, p4Material, dependencyMaterial, packageMaterial, pluggableSCMMaterial);
return new Pipeline(pipelineName, BuildCause.createWithModifications(ModificationsMother.modifyOneFile(materials, fixedMaterialRevisionForAllMaterials), ""), StageMother.passedStageInstance(stageName, jobName, pipelineName));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class PipelineServiceIntegrationTest method shouldReturnPMRsInCorrectOrder.
@Test
public void shouldReturnPMRsInCorrectOrder() throws Exception {
File file1 = new File("file1");
File file2 = new File("file2");
File file3 = new File("file3");
File file4 = new File("file4");
Material hg1 = new HgMaterial("url1", "Dest1");
Material hg2 = new HgMaterial("url2", "Dest2");
String[] hgRevs = new String[] { "h1", "h2" };
Date latestModification = new Date();
u.checkinFiles(hg2, "h2", a(file1, file2, file3, file4), ModifiedAction.added, org.apache.commons.lang.time.DateUtils.addDays(latestModification, -1));
u.checkinFiles(hg1, "h1", a(file1, file2, file3, file4), ModifiedAction.added, latestModification);
ScheduleTestUtil.AddedPipeline pair01 = u.saveConfigWith("pair01", "stageName", u.m(hg1), u.m(hg2));
u.runAndPass(pair01, hgRevs);
ReflectionUtil.invoke(pipelineSqlMapDao, "initDao");
Pipeline pipeline = pipelineService.mostRecentFullPipelineByName("pair01");
MaterialRevisions materialRevisions = pipeline.getBuildCause().getMaterialRevisions();
Materials materials = materialRevisions.getMaterials();
assertThat(materials.size(), is(2));
assertThat(materials.get(0), is(hg1));
assertThat(materials.get(1), is(hg2));
}
Aggregations