Search in sources :

Example 26 with TestSubprocessExecutionContext

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

the class HgMaterialDockerTest method shouldNotRefreshWorkingDirectoryIfPasswordIsNotSetInHgrcFileButIsAvailableInMaterialUrl.

@Test
public void shouldNotRefreshWorkingDirectoryIfPasswordIsNotSetInHgrcFileButIsAvailableInMaterialUrl() throws Exception {
    HgMaterial material = new HgMaterial("http://user1:password@localhost:9999", null);
    final List<Modification> modifications = material.latestModification(workingFolder, new TestSubprocessExecutionContext());
    final File unversionedFile = new File(workingFolder, "unversioned.txt");
    FileUtils.writeStringToFile(unversionedFile, "something", UTF_8);
    assertTrue(unversionedFile.exists());
    material.modificationsSince(workingFolder, new StringRevision(modifications.get(0).getRevision()), new TestSubprocessExecutionContext());
    assertTrue(unversionedFile.exists());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) File(java.io.File) Test(org.junit.Test)

Example 27 with TestSubprocessExecutionContext

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

the class GitMaterialShallowCloneTest method shouldNotUnshallowOnServerSideIfShallowClonePropertyIsOnAndRepoIsAlreadyShallow.

@Test
public void shouldNotUnshallowOnServerSideIfShallowClonePropertyIsOnAndRepoIsAlreadyShallow() {
    SystemEnvironment mockSystemEnvironment = mock(SystemEnvironment.class);
    GitMaterial material = new GitMaterial(repo.projectRepositoryUrl(), true);
    when(mockSystemEnvironment.get(SystemEnvironment.GO_SERVER_SHALLOW_CLONE)).thenReturn(true);
    material.modificationsSince(workingDir, REVISION_4, new TestSubprocessExecutionContext(mockSystemEnvironment, false));
    assertThat(localRepoFor(material).isShallow(), is(true));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) Test(org.junit.Test)

Example 28 with TestSubprocessExecutionContext

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

the class GitMaterialShallowCloneTest method shouldUnshallowServerSideRepoCompletelyOnRetrievingModificationsSincePreviousRevision.

@Test
public void shouldUnshallowServerSideRepoCompletelyOnRetrievingModificationsSincePreviousRevision() {
    SystemEnvironment mockSystemEnvironment = mock(SystemEnvironment.class);
    GitMaterial material = new GitMaterial(repo.projectRepositoryUrl(), true);
    when(mockSystemEnvironment.get(SystemEnvironment.GO_SERVER_SHALLOW_CLONE)).thenReturn(false);
    material.modificationsSince(workingDir, REVISION_4, new TestSubprocessExecutionContext(mockSystemEnvironment, true));
    assertThat(localRepoFor(material).isShallow(), is(false));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) Test(org.junit.Test)

Example 29 with TestSubprocessExecutionContext

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

the class GitTestRepo method addFileAndAmend.

public List<Modification> addFileAndAmend(String fileName, String message) throws IOException {
    File newFile = new File(gitRepo, fileName);
    newFile.createNewFile();
    new GitCommand(null, gitRepo, GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null).add(newFile);
    new GitCommandWithAmend(null, gitRepo, GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>()).commitWithAmend(message, gitRepo);
    return createMaterial().latestModification(temporaryFolder.newFolder(), new TestSubprocessExecutionContext());
}
Also used : HashMap(java.util.HashMap) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) File(java.io.File)

Example 30 with TestSubprocessExecutionContext

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

the class GitTestRepo method addFileAndPush.

public List<Modification> addFileAndPush(String fileName, String message) throws IOException {
    File newFile = new File(gitRepo, fileName);
    newFile.createNewFile();
    new GitCommand(null, gitRepo, GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null).add(newFile);
    new GitCommand(null, gitRepo, GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null).commit(message);
    return createMaterial().latestModification(temporaryFolder.newFolder(), new TestSubprocessExecutionContext());
}
Also used : HashMap(java.util.HashMap) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) File(java.io.File)

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