use of com.thoughtworks.go.helper.GitSubmoduleRepos in project gocd by gocd.
the class MaterialDatabaseGitWithSubmodulesUpdaterTest method repo.
protected TestRepo repo() throws Exception {
GitSubmoduleRepos testRepoWithExternal = new GitSubmoduleRepos();
testRepoWithExternal.addSubmodule("submodule-1", "sub1");
return testRepoWithExternal;
}
use of com.thoughtworks.go.helper.GitSubmoduleRepos in project gocd by gocd.
the class MaterialExpansionServiceTest method shouldNotExpandGitSubmodulesIntoMultipleMaterialsWhenExpandingGitMaterialForScheduling.
@Test
public void shouldNotExpandGitSubmodulesIntoMultipleMaterialsWhenExpandingGitMaterialForScheduling() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
submoduleRepos.addSubmodule("submodule-1", "sub1");
GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
when(materialConfigConverter.toMaterials(new MaterialConfigs(gitMaterial.config()))).thenReturn(new Materials(gitMaterial));
Materials materials = new Materials();
materialExpansionService.expandForScheduling(gitMaterial, materials);
assertThat(materials.size(), is(1));
assertThat(materials.get(0), is(gitMaterial));
}
use of com.thoughtworks.go.helper.GitSubmoduleRepos in project gocd by gocd.
the class GitMaterialTest method shouldHaveModificationsWhenSubmoduleIsRemoved.
@Test
public void shouldHaveModificationsWhenSubmoduleIsRemoved() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
File serverWorkingDir = TestFileUtil.createTempFolder("workingDir-" + System.currentTimeMillis());
List<Modification> beforeAdd = gitMaterial.latestModification(serverWorkingDir, new TestSubprocessExecutionContext());
submoduleRepos.removeSubmodule("sub1");
List<Modification> after = gitMaterial.modificationsSince(serverWorkingDir, new Modifications(beforeAdd).latestRevision(gitMaterial), new TestSubprocessExecutionContext());
assertThat(after.size(), is(1));
assertThat(after.get(0).getComment(), is("Removed submodule sub1"));
}
use of com.thoughtworks.go.helper.GitSubmoduleRepos in project gocd by gocd.
the class GitMaterialTest method shouldHaveModificationsWhenSubmoduleIsAdded.
@Test
public void shouldHaveModificationsWhenSubmoduleIsAdded() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
File serverWorkingDir = TestFileUtil.createTempFolder("workingDir-" + System.currentTimeMillis());
List<Modification> beforeAdd = gitMaterial.latestModification(serverWorkingDir, new TestSubprocessExecutionContext());
submoduleRepos.addSubmodule(SUBMODULE, "new-submodule");
List<Modification> afterAdd = gitMaterial.modificationsSince(serverWorkingDir, new Modifications(beforeAdd).latestRevision(gitMaterial), new TestSubprocessExecutionContext());
assertThat(afterAdd.size(), is(1));
assertThat(afterAdd.get(0).getComment(), is("Added submodule new-submodule"));
}
use of com.thoughtworks.go.helper.GitSubmoduleRepos in project gocd by gocd.
the class GitMaterialTest method shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo.
@Test
public void shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
StringRevision revision = new StringRevision("origin/master");
gitMaterial.updateTo(outputStreamConsumer, workingDir, new RevisionContext(revision), new TestSubprocessExecutionContext());
assertThat(new File(workingDir, "sub1"), exists());
submoduleRepos.removeSubmodule("sub1");
outputStreamConsumer = inMemoryConsumer();
gitMaterial.updateTo(outputStreamConsumer, workingDir, new RevisionContext(revision), new TestSubprocessExecutionContext());
assertThat(new File(workingDir, "sub1"), not(exists()));
}
Aggregations