Search in sources :

Example 56 with GitMaterial

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));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Test(org.junit.Test)

Example 57 with GitMaterial

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);
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) Test(org.junit.Test)

Example 58 with GitMaterial

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();
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 59 with GitMaterial

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();
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) TemporaryFolder(org.junit.rules.TemporaryFolder) ConsoleOutputStreamConsumer(com.thoughtworks.go.util.command.ConsoleOutputStreamConsumer) File(java.io.File) Test(org.junit.Test)

Example 60 with GitMaterial

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();
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) TemporaryFolder(org.junit.rules.TemporaryFolder) ConsoleOutputStreamConsumer(com.thoughtworks.go.util.command.ConsoleOutputStreamConsumer) File(java.io.File) Test(org.junit.Test)

Aggregations

GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)144 Test (org.junit.Test)136 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)74 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)55 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)29 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)19 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)18 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)18 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)12 File (java.io.File)12 Modification (com.thoughtworks.go.domain.materials.Modification)11 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)10 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)10 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)10 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)10 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)10 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)9 Material (com.thoughtworks.go.domain.materials.Material)8 Materials (com.thoughtworks.go.config.materials.Materials)7