use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnFalseUpWheNoProtocolIsGiven.
@Test
public void shouldReturnFalseUpWheNoProtocolIsGiven() throws Exception {
boolean isEqual = implementer.isUrlEqual("http://repo-url.git", new GitMaterial("repo-url.git"));
assertThat(isEqual, is(false));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnFalseForEmptyURLField.
@Test
public void shouldReturnFalseForEmptyURLField() throws Exception {
boolean isEqual = implementer.isUrlEqual("http://repo-url.git", new GitMaterial("http://"));
assertThat(isEqual, is(false));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldMatchFileBasedAccessWithoutAuth.
@Test
public void shouldMatchFileBasedAccessWithoutAuth() throws Exception {
boolean isEqual = implementer.isUrlEqual("/tmp/foo/repo-git", new GitMaterial("/tmp/foo/repo-git"));
assertThat(isEqual, is(true));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class PipelineSqlMapDaoCachingTest method shouldInvalidateCacheOfPipelineInstancesTriggeredWithMaterialRevision.
@Test
public void shouldInvalidateCacheOfPipelineInstancesTriggeredWithMaterialRevision() throws Exception {
GitMaterialInstance materialInstance = new GitMaterialInstance("url", "branch", "submodule", "flyweight");
String cacheKey = pipelineDao.cacheKeyForPipelineInstancesTriggeredWithDependencyMaterial("p1", materialInstance.getFingerprint(), "r1");
List<PipelineIdentifier> result = Arrays.asList(new PipelineIdentifier("p1", 1, "1"));
when(mockTemplate.queryForList(eq("pipelineInstancesTriggeredOffOfMaterialRevision"), anyString())).thenReturn(result);
List<PipelineIdentifier> actual = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial("p1", materialInstance, "r1");
assertThat(actual, hasSize(1));
assertThat((List<PipelineIdentifier>) goCache.get(cacheKey), hasSize(1));
MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(new GitMaterial("url", "branch"), new Modification("user", "comment", "email", new Date(), "r1")));
Pipeline pipeline = new Pipeline("p1", BuildCause.createWithModifications(materialRevisions, ""));
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((TransactionSynchronizationAdapter) invocation.getArguments()[0]).afterCommit();
return null;
}
}).when(transactionSynchronizationManager).registerSynchronization(any(TransactionSynchronization.class));
when(transactionTemplate.execute(any(TransactionCallback.class))).then(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((TransactionCallback) invocation.getArguments()[0]).doInTransaction(new SimpleTransactionStatus());
return null;
}
});
pipelineDao.save(pipeline);
assertThat(goCache.get(cacheKey), is(Matchers.nullValue()));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitMultipleMaterialsTest method shouldCloneMaterialToItsDestFolder.
@Test
public void shouldCloneMaterialToItsDestFolder() throws Exception {
GitMaterial material1 = repo.createMaterial("dest1");
MaterialRevision materialRevision = new MaterialRevision(material1, material1.latestModification(pipelineDir, new TestSubprocessExecutionContext()));
materialRevision.updateTo(pipelineDir, ProcessOutputStreamConsumer.inMemoryConsumer(), new TestSubprocessExecutionContext());
assertThat(new File(pipelineDir, "dest1").exists(), is(true));
assertThat(new File(pipelineDir, "dest1/.git").exists(), is(true));
}
Aggregations