use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldConvertExistingRepoToFullRepoWhenShallowCloneIsOff.
@Test
public void shouldConvertExistingRepoToFullRepoWhenShallowCloneIsOff() throws IOException {
String repositoryUrl = new GitTestRepo().projectRepositoryUrl();
GitMaterial shallowMaterial = new GitMaterial(repositoryUrl, true);
updateTo(shallowMaterial, new RevisionContext(REVISION_3), JobResult.Passed);
assertThat(localRepoFor(shallowMaterial).isShallow(), is(true));
GitMaterial fullMaterial = new GitMaterial(repositoryUrl, false);
updateTo(fullMaterial, new RevisionContext(REVISION_4), JobResult.Passed);
assertThat(localRepoFor(fullMaterial).isShallow(), is(false));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldCreateBuildCommandUpdateToSpecificRevision.
@Test
public void shouldCreateBuildCommandUpdateToSpecificRevision() throws Exception {
GitMaterial material = new GitMaterial(new GitTestRepo().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));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldNotDeleteAndRecheckoutDirectoryWhenBranchIsBlank.
/* This is to test the functionality of the private method isRepositoryChanged() */
@Test
public void shouldNotDeleteAndRecheckoutDirectoryWhenBranchIsBlank() throws Exception {
String repositoryUrl = new GitTestRepo().projectRepositoryUrl();
GitMaterial material = new GitMaterial(repositoryUrl, false);
updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
File shouldNotBeRemoved = new File(new File(workingDir, ".git"), "shouldNotBeRemoved");
FileUtils.writeStringToFile(shouldNotBeRemoved, "Text file");
GitMaterial material1 = new GitMaterial(repositoryUrl, " ");
updateTo(material1, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
assertThat("Should not have deleted whole folder", shouldNotBeRemoved.exists(), is(true));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldNotDeleteAndRecheckoutDirectoryWhenUrlSame.
@Test
public void shouldNotDeleteAndRecheckoutDirectoryWhenUrlSame() throws Exception {
GitMaterial material = new GitMaterial(new GitTestRepo().projectRepositoryUrl(), true);
updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
File shouldNotBeRemoved = new File(new File(workingDir, ".git"), "shouldNotBeRemoved");
FileUtils.writeStringToFile(shouldNotBeRemoved, "gundi");
assertThat(shouldNotBeRemoved.exists(), is(true));
updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
assertThat("Should not have deleted whole folder", shouldNotBeRemoved.exists(), is(true));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class GitMaterialShallowCloneTest method shouldBeAbleToUpdateToRevisionNotFetched.
@Test
public void shouldBeAbleToUpdateToRevisionNotFetched() {
GitMaterial material = new GitMaterial(repo.projectRepositoryUrl(), true);
material.updateTo(inMemoryConsumer(), workingDir, new RevisionContext(REVISION_3, REVISION_2, 2), context());
assertThat(localRepoFor(material).currentRevision(), is(REVISION_3.getRevision()));
assertThat(localRepoFor(material).containsRevisionInBranch(REVISION_2), is(true));
assertThat(localRepoFor(material).containsRevisionInBranch(REVISION_3), is(true));
}
Aggregations