Search in sources :

Example 16 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class GitMultipleMaterialsTest method shouldFindModificationsForBothMaterials.

@Test
public void shouldFindModificationsForBothMaterials() throws Exception {
    Materials materials = new Materials(repo.createMaterial("dest1"), repo.createMaterial("dest2"));
    String fileName = "newFile.txt";
    repo.addFileAndPush(fileName, "add a new file " + fileName);
    MaterialRevisions materialRevisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    assertThat(materialRevisions.getRevisions().size(), is(2));
    assertThat(materialRevisions, containsModifiedFile(fileName));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 17 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method shouldSetupEnvironmentVariableForDependencyMaterial.

@Test
public void shouldSetupEnvironmentVariableForDependencyMaterial() {
    EnvironmentVariableContext environmentVariableContext = doWorkWithMaterials(new Materials());
    assertThat("Properties: \n" + environmentVariableContext.getProperties(), environmentVariableContext.getProperty("GO_DEPENDENCY_LOCATOR_UPSTREAM1"), is("upstream1/0/first/1"));
    assertThat("Properties: \n" + environmentVariableContext.getProperties(), environmentVariableContext.getProperty("GO_DEPENDENCY_LABEL_UPSTREAM1"), is("upstream1-label"));
}
Also used : Materials(com.thoughtworks.go.config.materials.Materials) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 18 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method shouldSetUpRevisionIntoEnvironmentContextCorrectlyForMutipleMaterial.

@Test
public void shouldSetUpRevisionIntoEnvironmentContextCorrectlyForMutipleMaterial() throws Exception {
    svnMaterial.setFolder("svn-Dir");
    EnvironmentVariableContext environmentVariableContext = doWorkWithMaterials(new Materials(svnMaterial, hgMaterial));
    assertThat(environmentVariableContext.getProperty("GO_REVISION_SVN_DIR"), is("3"));
    assertThat(environmentVariableContext.getProperty("GO_REVISION_HG_DIR"), is("ca3ebb67f527c0ad7ed26b789056823d8b9af23f"));
}
Also used : Materials(com.thoughtworks.go.config.materials.Materials) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 19 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method shouldSetEnvironmentVariableForSvnExternal.

@Test
public void shouldSetEnvironmentVariableForSvnExternal() throws Exception {
    svnRepoFixture.createExternals(svnRepoFixture.getEnd2EndRepoUrl());
    command = new SvnCommand(null, svnRepoFixture.getEnd2EndRepoUrl(), null, null, true);
    svnMaterial = SvnMaterial.createSvnMaterialWithMock(command);
    svnMaterial.setFolder("svn-Dir");
    EnvironmentVariableContext environmentVariableContext = doWorkWithMaterials(new Materials(svnMaterial));
    assertThat(environmentVariableContext.getProperty("GO_REVISION_SVN_DIR"), is("4"));
    assertThat(environmentVariableContext.getProperty("GO_REVISION_SVN_DIR_EXTERNAL"), is("4"));
}
Also used : Materials(com.thoughtworks.go.config.materials.Materials) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 20 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method shouldSetupEnvironmentVariableUsingDependencyMaterialName.

@Test
public void shouldSetupEnvironmentVariableUsingDependencyMaterialName() {
    EnvironmentVariableContext environmentVariableContext = doWorkWithMaterials(new Materials());
    assertThat("Properties: \n" + environmentVariableContext.getProperties(), environmentVariableContext.getProperty("GO_DEPENDENCY_LOCATOR_DEPENDENCY_MATERIAL_NAME"), is("upstream2/0/first/1"));
    assertThat("Properties: \n" + environmentVariableContext.getProperties(), environmentVariableContext.getProperty("GO_DEPENDENCY_LABEL_DEPENDENCY_MATERIAL_NAME"), is("upstream2-label"));
}
Also used : Materials(com.thoughtworks.go.config.materials.Materials) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Aggregations

Materials (com.thoughtworks.go.config.materials.Materials)58 Test (org.junit.Test)48 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)24 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)16 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)14 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)13 Material (com.thoughtworks.go.domain.materials.Material)10 Modification (com.thoughtworks.go.domain.materials.Modification)10 File (java.io.File)10 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)9 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)9 Date (java.util.Date)9 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)8 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)5 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)5 Stage (com.thoughtworks.go.domain.Stage)5 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)5 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)4