Search in sources :

Example 21 with GitTestRepo

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

the class GitMaterialUpdaterTest method shouldCreateBuildCommandUpdateToSpecificRevision.

@Test
public void shouldCreateBuildCommandUpdateToSpecificRevision() throws Exception {
    GitMaterial material = new GitMaterial(new GitTestRepo(temporaryFolder).projectRepositoryUrl(), true);
    File newFile = new File(workingDir, "second.txt");
    updateTo(material, new RevisionContext(REVISION_1, REVISION_0, 2), JobResult.Passed);
    assertThat(console.output(), containsString("Start updating files at revision " + REVISION_1.getRevision()));
    assertThat(newFile.exists(), is(false));
    console.clear();
    updateTo(material, new RevisionContext(REVISION_2, REVISION_1, 2), JobResult.Passed);
    assertThat(console.output(), containsString("Start updating files at revision " + REVISION_2.getRevision()));
    assertThat(newFile.exists(), is(true));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) File(java.io.File) Test(org.junit.Test)

Example 22 with GitTestRepo

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

the class GitMaterialUpdaterTest method shouldDeleteAndRecheckoutDirectoryWhenUrlChanges.

@Test
public void shouldDeleteAndRecheckoutDirectoryWhenUrlChanges() throws Exception {
    updateTo(new GitMaterial(new GitTestRepo(temporaryFolder).projectRepositoryUrl(), true), new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
    File shouldBeRemoved = new File(workingDir, "shouldBeRemoved");
    shouldBeRemoved.createNewFile();
    assertThat(shouldBeRemoved.exists(), is(true));
    String repositoryUrl = new GitTestRepo(temporaryFolder).projectRepositoryUrl();
    GitMaterial material = new GitMaterial(repositoryUrl, true);
    updateTo(material, new RevisionContext(REVISION_4), JobResult.Passed);
    assertThat(localRepoFor(material).workingRepositoryUrl().forCommandline(), is(repositoryUrl));
    assertThat(shouldBeRemoved.exists(), is(false));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 23 with GitTestRepo

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

the class GitMaterialShallowCloneTest method setup.

@Before
public void setup() throws Exception {
    repo = new GitTestRepo(temporaryFolder);
    workingDir = temporaryFolder.newFolder("working-dir");
}
Also used : GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) Before(org.junit.Before)

Example 24 with GitTestRepo

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

the class GitMaterialTest method shouldDeleteAndRecheckoutDirectoryWhenUrlChanges.

@Test
public void shouldDeleteAndRecheckoutDirectoryWhenUrlChanges() throws Exception {
    git.latestModification(workingDir, new TestSubprocessExecutionContext());
    File shouldBeRemoved = new File(workingDir, "shouldBeRemoved");
    shouldBeRemoved.createNewFile();
    assertThat(shouldBeRemoved.exists(), is(true));
    git = new GitMaterial(new GitTestRepo(temporaryFolder).projectRepositoryUrl());
    git.latestModification(workingDir, new TestSubprocessExecutionContext());
    assertThat("Should have deleted whole folder", shouldBeRemoved.exists(), is(false));
}
Also used : GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 25 with GitTestRepo

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

the class MaterialDatabaseUpdaterIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    dbHelper.onSetUp();
    testRepo = new GitTestRepo(temporaryFolder);
    MaterialService slowMaterialService = new MaterialServiceWhichSlowsDownFirstTimeModificationCheck(materialRepository, goConfigService, securityService, packageRepositoryExtension, scmExtension);
    LegacyMaterialChecker materialChecker = new LegacyMaterialChecker(slowMaterialService, subprocessExecutionContext);
    ScmMaterialUpdater scmMaterialUpdater = new ScmMaterialUpdater(materialRepository, materialChecker, subprocessExecutionContext, slowMaterialService);
    transactionTemplateWithInvocationCount = new TransactionTemplateWithInvocationCount(transactionTemplate);
    updater = new MaterialDatabaseUpdater(materialRepository, serverHealthService, transactionTemplateWithInvocationCount, dependencyMaterialUpdater, scmMaterialUpdater, packageMaterialUpdater, pluggableSCMMaterialUpdater, materialExpansionService);
}
Also used : MaterialService(com.thoughtworks.go.server.service.MaterialService) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) Before(org.junit.Before)

Aggregations

GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)25 Test (org.junit.Test)20 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)9 Modification (com.thoughtworks.go.domain.materials.Modification)7 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)7 File (java.io.File)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 Before (org.junit.Before)5 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)2 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)1 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)1 HgTestRepo (com.thoughtworks.go.helper.HgTestRepo)1 SvnTestRepo (com.thoughtworks.go.helper.SvnTestRepo)1 ScheduleOptions (com.thoughtworks.go.server.scheduling.ScheduleOptions)1