|
1 | 1 | package org.kohsuke.github; |
2 | 2 |
|
3 | 3 | import com.github.tomakehurst.wiremock.core.WireMockConfiguration; |
4 | | -import org.junit.After; |
5 | | -import org.junit.Before; |
6 | 4 | import org.junit.Test; |
7 | 5 | import org.kohsuke.github.GHOrganization.Permission; |
8 | 6 | import org.kohsuke.github.GHOrganization.RepositoryRole; |
@@ -44,21 +42,21 @@ public GHOrganizationTest() { |
44 | 42 | * @throws IOException |
45 | 43 | * Signals that an I/O exception has occurred. |
46 | 44 | */ |
47 | | - @Before |
48 | | - @After |
49 | | - public void cleanUpTeam() throws IOException { |
50 | | - // Cleanup is only needed when proxying |
51 | | - if (!mockGitHub.isUseProxy()) { |
52 | | - return; |
53 | | - } |
54 | | - |
55 | | - GHTeam team = getNonRecordingGitHub().getOrganization(GITHUB_API_TEST_ORG).getTeamByName(TEAM_NAME_CREATE); |
56 | | - if (team != null) { |
57 | | - team.delete(); |
58 | | - } |
59 | | - |
60 | | - getNonRecordingGitHub().getOrganization(GITHUB_API_TEST_ORG).enableOrganizationProjects(true); |
61 | | - } |
| 45 | + // @Before |
| 46 | + // @After |
| 47 | + // public void cleanUpTeam() throws IOException { |
| 48 | + // // Cleanup is only needed when proxying |
| 49 | + // if (!mockGitHub.isUseProxy()) { |
| 50 | + // return; |
| 51 | + // } |
| 52 | + // |
| 53 | + // GHTeam team = getNonRecordingGitHub().getOrganization(GITHUB_API_TEST_ORG).getTeamByName(TEAM_NAME_CREATE); |
| 54 | + // if (team != null) { |
| 55 | + // team.delete(); |
| 56 | + // } |
| 57 | + // |
| 58 | + // getNonRecordingGitHub().getOrganization(GITHUB_API_TEST_ORG).enableOrganizationProjects(true); |
| 59 | + // } |
62 | 60 |
|
63 | 61 | /** |
64 | 62 | * Test are organization projects enabled. |
@@ -264,6 +262,37 @@ public void testCreateRepositoryWithTemplateAndGHRepository() throws IOException |
264 | 262 |
|
265 | 263 | } |
266 | 264 |
|
| 265 | + /** |
| 266 | + * Test create a repository from a template with all branches included |
| 267 | + * |
| 268 | + * @throws IOException |
| 269 | + * Signals that an I/O exception has occurred. |
| 270 | + * @throws InterruptedException |
| 271 | + * Signals that Thread.sleep() was interrupted |
| 272 | + */ |
| 273 | + |
| 274 | + @Test |
| 275 | + public void testCreateRepositoryWithTemplateAndIncludeAllBranches() throws IOException, InterruptedException { |
| 276 | + cleanupRepository(GITHUB_API_TEST_ORG + '/' + GITHUB_API_TEST); |
| 277 | + |
| 278 | + GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); |
| 279 | + GHRepository templateRepository = org.getRepository(GITHUB_API_TEMPLATE_TEST); |
| 280 | + |
| 281 | + GHRepository repository = gitHub.createRepository(GITHUB_API_TEST) |
| 282 | + .fromTemplateRepository(templateRepository) |
| 283 | + .includeAllBranches(true) |
| 284 | + .owner(GITHUB_API_TEST_ORG) |
| 285 | + .create(); |
| 286 | + |
| 287 | + assertThat(repository, notNullValue()); |
| 288 | + |
| 289 | + // give it a moment for branches to be created |
| 290 | + Thread.sleep(1500); |
| 291 | + |
| 292 | + assertThat(repository.getBranches().keySet(), equalTo(templateRepository.getBranches().keySet())); |
| 293 | + |
| 294 | + } |
| 295 | + |
267 | 296 | /** |
268 | 297 | * Test create team. |
269 | 298 | * |
|
0 commit comments