Skip to content

Commit f3528d9

Browse files
committed
Move team cleanup to @before method as per GitHub review.
Removed constant for TEAM_NAME as it is now only used once in the method.
1 parent c0a4152 commit f3528d9

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/test/java/org/kohsuke/github/GHOrganizationTest.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,29 @@ public void testInviteUser() throws IOException {
5858
// assertTrue(org.hasMember(user));
5959
}
6060

61+
@Before
62+
public void cleanUpTeam() throws IOException {
63+
// Cleanup is only needed when proxying
64+
if (!mockGitHub.isUseProxy()) {
65+
return;
66+
}
67+
68+
GHTeam team = gitHubBeforeAfter.getOrganization(GITHUB_API_TEST_ORG).
69+
getTeamByName("create-team-test");
70+
if (team != null) {
71+
team.delete();
72+
}
73+
}
74+
6175
@Test
6276
public void testCreateTeamWithRepoAccess() throws IOException {
6377
String REPO_NAME = "github-api";
64-
String TEAM_NAME = "create-team-test";
6578

6679
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
6780
GHRepository repo = org.getRepository(REPO_NAME);
6881

69-
// Clean up team if exists.
70-
GHTeam existingTeam = org.getTeamByName(TEAM_NAME);
71-
if (existingTeam != null) {
72-
existingTeam.delete();
73-
}
74-
7582
// Create team with access to repository. Check access was granted.
76-
GHTeam team = org.createTeam(TEAM_NAME, GHOrganization.Permission.PUSH, repo);
83+
GHTeam team = org.createTeam("create-team-test", GHOrganization.Permission.PUSH, repo);
7784
Assert.assertTrue(team.getRepositories().containsKey(REPO_NAME));
7885
}
7986
}

0 commit comments

Comments
 (0)