Search in sources :

Example 6 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class SvnExternalTest method shouldGetLatestRevision.

@Test
public void shouldGetLatestRevision() {
    SvnMaterial svn = svnMaterial(svnRepo.projectRepositoryUrl(), null);
    SvnMaterial svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
    final Materials materials = new Materials(svn, svnExt);
    final MaterialRevisions materialRevisions = materials.latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
    assertThat(materialRevisions.numberOfRevisions(), is(2));
    MaterialRevision main = materialRevisions.getRevisions().get(0);
    assertThat(main.getMaterial(), is(svn));
    assertThat(main.getModifications().size(), is(1));
    assertThat(main.getRevision().getRevision(), is("5"));
    MaterialRevision external = materialRevisions.getRevisions().get(1);
    assertThat(external.getMaterial(), is(svnExt));
    assertThat(external.getRevision().getRevision(), is("4"));
    assertThat(external.getModifications().size(), is(1));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 7 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class SvnMaterialMockitoTest method shouldNotDeleteWorkingDirIfSvnRepositoryUsesFileProtocol.

@Test
public void shouldNotDeleteWorkingDirIfSvnRepositoryUsesFileProtocol() throws IOException {
    Subversion subversion = mock(Subversion.class);
    when(subversion.getUserName()).thenReturn("");
    when(subversion.getPassword()).thenReturn("");
    when(subversion.isCheckExternals()).thenReturn(false);
    File workingCopy = createSvnWorkingCopy(true);
    when(subversion.workingRepositoryUrl(workingCopy)).thenReturn(workingCopy.getPath());
    String url = "file://" + workingCopy.getPath();
    when(subversion.getUrl()).thenReturn(new UrlArgument(url));
    SvnMaterial svnMaterial = SvnMaterial.createSvnMaterialWithMock(subversion);
    svnMaterial.setUrl(url);
    svnMaterial.updateTo(outputStreamConsumer, workingCopy, new RevisionContext(revision), new TestSubprocessExecutionContext());
    assertThat(workingCopy.exists(), is(true));
    verify(subversion).updateTo(outputStreamConsumer, workingCopy, revision);
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) File(java.io.File) Test(org.junit.Test)

Example 8 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class TfsMaterialTest method shouldCheckConnection.

@Test
public void shouldCheckConnection() {
    TestSubprocessExecutionContext execCtx = new TestSubprocessExecutionContext();
    TfsCommand tfsCommand = mock(TfsCommand.class);
    doNothing().when(tfsCommand).checkConnection();
    TfsMaterial spy = spy(tfsMaterialFirstCollectionFirstProject);
    doReturn(tfsCommand).when(spy).tfs(execCtx);
    assertThat(spy.checkConnection(execCtx), Is.is(ValidationBean.valid()));
    verify(tfsCommand, times(1)).checkConnection();
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) TfsCommand(com.thoughtworks.go.domain.materials.tfs.TfsCommand) Test(org.junit.Test)

Example 9 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class HgMultipleMaterialsTest method shouldCloneMaterialToItsDestFolder.

@Test
public void shouldCloneMaterialToItsDestFolder() throws Exception {
    HgMaterial material1 = repo.createMaterial("dest1");
    MaterialRevision materialRevision = new MaterialRevision(material1, material1.latestModification(pipelineDir, new TestSubprocessExecutionContext()));
    materialRevision.updateTo(pipelineDir, ProcessOutputStreamConsumer.inMemoryConsumer(), new TestSubprocessExecutionContext());
    assertThat(new File(pipelineDir, "dest1").exists(), is(true));
    assertThat(new File(pipelineDir, "dest1/.hg").exists(), is(true));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) Test(org.junit.Test)

Example 10 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class P4MaterialTestBase method shouldCheckConnection.

@Test
public void shouldCheckConnection() throws Exception {
    P4Material p4Material = new P4Material("localhost:9876", "p4view");
    p4Material.setPassword("secret");
    p4Material.setUseTickets(false);
    ValidationBean validation = p4Material.checkConnection(new TestSubprocessExecutionContext());
    assertThat(validation.isValid(), is(false));
    assertThat(validation.getError(), containsString("Unable to connect to server localhost:9876"));
    assertThat(validation.getError(), not(containsString("secret")));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Aggregations

TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)30 Test (org.junit.Test)24 File (java.io.File)15 Modification (com.thoughtworks.go.domain.materials.Modification)9 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)5 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)5 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)4 Materials (com.thoughtworks.go.config.materials.Materials)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 TfsCommand (com.thoughtworks.go.domain.materials.tfs.TfsCommand)3 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)2 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)2 Material (com.thoughtworks.go.domain.materials.Material)2 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)2 ValidationBean (com.thoughtworks.go.domain.materials.ValidationBean)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2