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(temporaryFolder).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 shouldNotDeleteAndRecheckoutDirectoryWhenBranchIsBlank.
/* This is to test the functionality of the private method isRepositoryChanged() */
@Test
public void shouldNotDeleteAndRecheckoutDirectoryWhenBranchIsBlank() throws Exception {
String repositoryUrl = new GitTestRepo(temporaryFolder).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", UTF_8);
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 shouldDeleteAndRecheckoutDirectoryWhenBranchChanges.
@Test
public void shouldDeleteAndRecheckoutDirectoryWhenBranchChanges() throws Exception {
GitTestRepo repoWithBranch = GitTestRepo.testRepoAtBranch(GIT_FOO_BRANCH_BUNDLE, "foo", temporaryFolder);
GitMaterial material = new GitMaterial(repoWithBranch.projectRepositoryUrl(), true);
updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
InMemoryStreamConsumer output = inMemoryConsumer();
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(workingDir).run(output, "");
assertThat(output.getStdOut(), Is.is("* master"));
GitMaterial material1 = new GitMaterial(repoWithBranch.projectRepositoryUrl(), "foo", null, true);
updateTo(material1, new RevisionContext(new StringRevision("origin/foo")), JobResult.Passed);
output = inMemoryConsumer();
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(workingDir).run(output, "");
assertThat(output.getStdOut(), Is.is("* foo"));
}
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(temporaryFolder).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", UTF_8);
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 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));
}
Aggregations