use of com.thoughtworks.go.domain.materials.RevisionContext 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));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class HgMaterialUpdaterTest method shouldUpdateToSpecificRevision.
@Test
public void shouldUpdateToSpecificRevision() throws Exception {
updateTo(hgMaterial, new RevisionContext(REVISION_0), JobResult.Passed);
File end2endFolder = new File(workingFolder, "end2end");
assertThat(end2endFolder.listFiles().length, is(3));
updateTo(hgMaterial, new RevisionContext(REVISION_1), JobResult.Passed);
assertThat(end2endFolder.listFiles().length, is(4));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class HgMaterialUpdaterTest method shouldLogRepoInfoToConsoleOutWithoutFolder.
@Test
public void shouldLogRepoInfoToConsoleOutWithoutFolder() throws Exception {
updateTo(hgMaterial, new RevisionContext(new StringRevision("0")), JobResult.Passed);
assertThat(console.output(), containsString(format("Start updating %s at revision %s from %s", "files", "0", hgMaterial.getUrl())));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class HgMaterialUpdaterTest method shouldPullNewChangesFromRemoteBeforeUpdating.
@Test
public void shouldPullNewChangesFromRemoteBeforeUpdating() throws Exception {
File newWorkingFolder = temporaryFolder.newFolder("newWorkingFolder");
updateTo(hgMaterial, new RevisionContext(REVISION_0), JobResult.Passed);
String repositoryUrl = hgTestRepo.projectRepositoryUrl();
HgMaterial material = MaterialsMother.hgMaterial(repositoryUrl);
assertThat(material.getUrl(), is(hgMaterial.getUrl()));
updateTo(material, new RevisionContext(REVISION_0), JobResult.Passed, newWorkingFolder);
hgTestRepo.commitAndPushFile("SomeDocumentation.txt", "whatever");
List<Modification> modification = hgMaterial.latestModification(workingFolder, new TestSubprocessExecutionContext());
StringRevision revision = new StringRevision(modification.get(0).getRevision());
updateTo(material, new RevisionContext(revision), JobResult.Passed, newWorkingFolder);
assertThat(console.output(), containsString("Start updating files at revision " + revision.getRevision()));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class HgMaterialUpdaterTest method shouldNotDeleteAndRecheckoutDirectoryUnlessUrlChanges.
@Test
public void shouldNotDeleteAndRecheckoutDirectoryUnlessUrlChanges() throws Exception {
String repositoryUrl = new HgTestRepo(temporaryFolder).projectRepositoryUrl();
HgMaterial material = MaterialsMother.hgMaterial(repositoryUrl);
updateTo(material, new RevisionContext(REVISION_0), JobResult.Passed);
File shouldNotBeRemoved = new File(workingFolder, "shouldBeRemoved");
shouldNotBeRemoved.createNewFile();
assertThat(shouldNotBeRemoved.exists(), is(true));
updateTo(material, new RevisionContext(REVISION_2), JobResult.Passed);
assert (MaterialUrl.sameUrl(material.getUrl(), repositoryUrl));
assertThat(shouldNotBeRemoved.exists(), is(true));
}
Aggregations