use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnTrueWhenBasicAuthWithOnlyUsernameIsProvidedInURL.
@Test
public void shouldReturnTrueWhenBasicAuthWithOnlyUsernameIsProvidedInURL() throws Exception {
boolean isEqual = implementer.isUrlEqual("http://repo-url.git", new GitMaterial("http://user@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 shouldReturnEmptyListIfParamIsMissingForRepoURL.
@Test
public void shouldReturnEmptyListIfParamIsMissingForRepoURL() 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));
Set<Material> actual = implementer.prune(materials, new HashMap());
assertThat(actual.size(), is(0));
verifyNoMoreInteractions(material1);
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class MercurialPostCommitHookImplementerTest method shouldPruneMercurialMaterialsWhichMatchIncomingURL.
@Test
public void shouldPruneMercurialMaterialsWhichMatchIncomingURL() throws Exception {
HgMaterial material1 = mock(HgMaterial.class);
when(material1.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
HgMaterial material2 = mock(HgMaterial.class);
when(material2.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
HgMaterial material3 = mock(HgMaterial.class);
when(material3.getUrlArgument()).thenReturn(new UrlArgument("ssh://repo1.something.local"));
GitMaterial material4 = mock(GitMaterial.class);
when(material4.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
Set<Material> materials = new HashSet<>(Arrays.asList(material1, material2, material3, material4));
Map params = new HashMap();
params.put(MercurialPostCommitHookImplementer.REPO_URL_PARAM_KEY, "http://repo1.something.local");
Set<Material> actual = implementer.prune(materials, params);
assertThat(actual.size(), is(2));
assertThat(actual, hasItem(material1));
assertThat(actual, hasItem(material2));
verify(material1).getUrlArgument();
verify(material2).getUrlArgument();
verify(material3).getUrlArgument();
verify(material4, times(0)).getUrlArgument();
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class MaterialsTest method shouldNotRemoveJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsTrue.
@Test
public void shouldNotRemoveJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsTrue() throws Exception {
TemporaryFolder temporaryFolder = new TemporaryFolder();
temporaryFolder.create();
File junkFolder = temporaryFolder.newFolder("junk-folder");
Materials materials = new Materials();
GitMaterial gitMaterial = new GitMaterial("http://some-url.com", "some-branch");
materials.add(gitMaterial);
materials.cleanUp(temporaryFolder.getRoot(), mock(ConsoleOutputStreamConsumer.class));
assertThat(junkFolder.exists(), is(true));
temporaryFolder.delete();
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class MaterialsTest method shouldRemoveJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsFalse.
@Test
public void shouldRemoveJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsFalse() throws Exception {
TemporaryFolder temporaryFolder = new TemporaryFolder();
temporaryFolder.create();
File junkFolder = temporaryFolder.newFolder("junk-folder");
Materials materials = new Materials();
GitMaterial gitMaterial = new GitMaterial("http://some-url.com", "some-branch", "some-folder");
materials.add(gitMaterial);
materials.cleanUp(temporaryFolder.getRoot(), mock(ConsoleOutputStreamConsumer.class));
assertThat(junkFolder.exists(), is(false));
temporaryFolder.delete();
}
Aggregations