use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class MixedMultipleMaterialsTest method shouldGetLatestModificationswithThreeRepositories.
@Test
public void shouldGetLatestModificationswithThreeRepositories() throws Exception {
HgMaterial hgMaterial = hgRepo.material();
SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
GitMaterial gitMaterial = gitRepo.createMaterial();
Materials materials = new Materials(hgMaterial, svnMaterial, gitMaterial);
MaterialRevisions revisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
assertThat(revisions.getMaterialRevision(0).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(0).getRevision(), is(new Modifications(hgRepo.latestModifications()).latestRevision(hgMaterial)));
assertThat(revisions.getMaterialRevision(1).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(1).getRevision(), is(latestRevision(svnMaterial, pipelineDir, new TestSubprocessExecutionContext())));
assertThat(revisions.getMaterialRevision(2).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(2).getRevision(), is(new Modifications(gitRepo.latestModifications()).latestRevision(gitMaterial)));
assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(3));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class MaterialDatabaseUpdaterTest method shouldFailWithAReasonableMessageWhenExceptionMessageIsNull.
@Test
public void shouldFailWithAReasonableMessageWhenExceptionMessageIsNull() throws Exception {
Material material = new GitMaterial("url", "branch");
Exception exceptionWithNullMessage = new RuntimeException(null, new RuntimeException("Inner exception has non-null message"));
String message = "Modification check failed for material: " + material.getLongDescription();
when(materialRepository.findMaterialInstance(material)).thenThrow(exceptionWithNullMessage);
try {
materialDatabaseUpdater.updateMaterial(material);
fail("should have thrown exception");
} catch (Exception e) {
assertThat(e, is(exceptionWithNullMessage));
}
verify(healthService).update(ServerHealthState.error(message, "Unknown error", HealthStateType.general(HealthStateScope.forMaterial(material))));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnTrueWhenURLIsAnExactMatch.
@Test
public void shouldReturnTrueWhenURLIsAnExactMatch() throws Exception {
boolean isEqual = implementer.isUrlEqual("http://repo-url.git", new GitMaterial("http://repo-url.git"));
assertThat(isEqual, is(true));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnEmptyListIfParamHasNoValueForRepoURL.
@Test
public void shouldReturnEmptyListIfParamHasNoValueForRepoURL() throws Exception {
GitMaterial material1 = mock(GitMaterial.class);
when(material1.getUrlArgument()).thenReturn(new UrlArgument("https://machine.local.git"));
Set<Material> materials = new HashSet<>(Arrays.asList(material1));
HashMap params = new HashMap();
params.put(GitPostCommitHookImplementer.REPO_URL_PARAM_KEY, "");
Set<Material> actual = implementer.prune(materials, params);
assertThat(actual.size(), is(0));
verifyNoMoreInteractions(material1);
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnTrueWhenBasicAuthWithoutPasswordIsProvidedInURL.
@Test
public void shouldReturnTrueWhenBasicAuthWithoutPasswordIsProvidedInURL() throws Exception {
boolean isEqual = implementer.isUrlEqual("http://repo-url.git", new GitMaterial("http://user:@repo-url.git"));
assertThat(isEqual, is(true));
}
Aggregations