Skip to content

Commit 35c8cfa

Browse files
committed
Push method code coverage bar to 50 percent
This change adds or update a swath of tests to push method code coverage numbers up. Yes, method coverage is not super meaningful, but it is one metric that we can use to ensure at least minimal coverage of this library. Almost no product changes in here.
1 parent 8e6dbf3 commit 35c8cfa

258 files changed

Lines changed: 49288 additions & 2256 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
<okio.version>2.5.0</okio.version>
4242
<spotless-maven-plugin.goal>apply</spotless-maven-plugin.goal>
4343
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
44-
<jacoco.coverage.target.bundle.method>0.60</jacoco.coverage.target.bundle.method>
45-
<jacoco.coverage.target.class.method>0.25</jacoco.coverage.target.class.method>
44+
<jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
45+
<jacoco.coverage.target.class.method>0.50</jacoco.coverage.target.class.method>
4646
<!-- For non-ci builds we'd like the build to still complete if jacoco metrics aren't met. -->
4747
<jacoco.haltOnFailure>false</jacoco.haltOnFailure>
4848
<jjwt.suite.version>0.11.2</jjwt.suite.version>
@@ -153,59 +153,39 @@
153153
<!-- Sample only -->
154154
<exclude>org.kohsuke.github.example.*</exclude>
155155

156-
<!-- No methods -->
157-
<exclude>org.kohsuke.github.internal.Previews</exclude>
158156

159157
<!-- Deprecated -->
160158
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
161159
<exclude>org.kohsuke.github.EnforcementLevel</exclude>
162160
<exclude>org.kohsuke.github.GHPerson.1</exclude>
163-
164-
<!-- These fail coverage on windows because tests are disabled -->
165-
<exclude>org.kohsuke.github.GHAsset</exclude>
166-
<exclude>org.kohsuke.github.GHReleaseBuilder</exclude>
167-
<exclude>org.kohsuke.github.GHRelease</exclude>
161+
<!-- TODO: Some coverage, but more needed -->
162+
<exclude>org.kohsuke.github.GHPullRequestReviewBuilder.DraftReviewComment</exclude>
163+
<exclude>org.kohsuke.github.GHIssue.PullRequest</exclude>
164+
<exclude>org.kohsuke.github.GHCommitSearchBuilder</exclude>
165+
<exclude>org.kohsuke.github.GHRepositorySearchBuilder</exclude>
166+
<exclude>org.kohsuke.github.GHUserSearchBuilder</exclude>
168167

169168
<!-- TODO: These still need test coverage -->
170169
<exclude>org.kohsuke.github.GHBranchProtection.RequiredSignatures</exclude>
171170
<exclude>org.kohsuke.github.GHBranchProtectionBuilder.Restrictions</exclude>
172171
<exclude>org.kohsuke.github.GHBranchProtection.Restrictions</exclude>
173172
<exclude>org.kohsuke.github.GHCommentAuthorAssociation</exclude>
174-
<exclude>org.kohsuke.github.GHCommitBuilder.UserInfo</exclude>
175-
<exclude>org.kohsuke.github.GHCommitState</exclude>
176173
<exclude>org.kohsuke.github.GHCompare.Commit</exclude>
177174
<exclude>org.kohsuke.github.GHCompare.InnerCommit</exclude>
178-
<exclude>org.kohsuke.github.GHCompare.Status</exclude>
179175
<exclude>org.kohsuke.github.GHCompare.Tree</exclude>
180176
<exclude>org.kohsuke.github.GHCompare.User</exclude>
181177
<exclude>org.kohsuke.github.GHCompare</exclude>
182178
<exclude>org.kohsuke.github.GHDeployKey</exclude>
183-
<exclude>org.kohsuke.github.GHDeploymentStatusBuilder</exclude>
184-
<exclude>org.kohsuke.github.GHDirection</exclude>
185179
<exclude>org.kohsuke.github.GHEmail</exclude>
186-
<exclude>org.kohsuke.github.GHEventPayload.Ping</exclude>
187-
<exclude>org.kohsuke.github.GHEventPayload.Release</exclude>
188-
<exclude>org.kohsuke.github.GHException</exclude>
189-
<exclude>org.kohsuke.github.GHHook</exclude>
190-
<exclude>org.kohsuke.github.GHHooks.OrgContext</exclude>
191180
<exclude>org.kohsuke.github.GHInvitation</exclude>
192-
<exclude>org.kohsuke.github.GHMilestoneState</exclude>
193-
<exclude>org.kohsuke.github.GHOrgHook</exclude>
194-
<exclude>org.kohsuke.github.GHProject.ProjectStateFilter</exclude>
195181
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Authorship</exclude>
196182
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Commit</exclude>
197183
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.CommitPointer</exclude>
198184
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Tree</exclude>
199185
<exclude>org.kohsuke.github.GHPullRequestCommitDetail</exclude>
200186
<exclude>org.kohsuke.github.GHPullRequestFileDetail</exclude>
201-
<exclude>org.kohsuke.github.GHPullRequestQueryBuilder.Sort</exclude>
202187
<exclude>org.kohsuke.github.GHReleaseUpdater</exclude>
203-
<exclude>org.kohsuke.github.GHRepository.ForkSort</exclude>
204188
<exclude>org.kohsuke.github.GHRequestedAction</exclude>
205-
<exclude>org.kohsuke.github.GHStargazer</exclude>
206-
<exclude>org.kohsuke.github.GHTagObject</exclude>
207-
<exclude>org.kohsuke.github.GHTeam.Role</exclude>
208-
<exclude>org.kohsuke.github.GHUserSearchBuilder.Sort</exclude>
209189
<exclude>org.kohsuke.github.GHVerifiedKey</exclude>
210190
</excludes>
211191
</rule>
@@ -592,6 +572,8 @@
592572
</os>
593573
</activation>
594574
<properties>
575+
<!-- Only fail code coverage on non-windows machines -->
576+
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
595577
<spotless-maven-plugin.goal>check</spotless-maven-plugin.goal>
596578
</properties>
597579
</profile>
@@ -602,9 +584,6 @@
602584
<name>enable-ci</name>
603585
</property>
604586
</activation>
605-
<properties>
606-
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
607-
</properties>
608587
<build>
609588
<plugins>
610589
<plugin>

src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,20 @@ public URL getHtmlUrl() {
153153
* @return the api route
154154
*/
155155
protected String getApiRoute() {
156-
return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + getId();
156+
return getApiRoute(false);
157+
}
158+
159+
/**
160+
* Gets api route.
161+
*
162+
* @param includePullNumber
163+
* if true, includes the owning pull request's number in the route.
164+
*
165+
* @return the api route
166+
*/
167+
protected String getApiRoute(boolean includePullNumber) {
168+
return "/repos/" + owner.getRepository().getFullName() + "/pulls"
169+
+ (includePullNumber ? "/" + owner.getNumber() : "") + "/comments/" + getId();
157170
}
158171

159172
/**
@@ -192,8 +205,7 @@ public GHPullRequestReviewComment reply(String body) throws IOException {
192205
return owner.root.createRequest()
193206
.method("POST")
194207
.with("body", body)
195-
.with("in_reply_to", getId())
196-
.withUrlPath(getApiRoute() + "/comments")
208+
.withUrlPath(getApiRoute(true) + "/replies")
197209
.fetch(GHPullRequestReviewComment.class)
198210
.wrapUp(owner);
199211
}

src/main/java/org/kohsuke/github/GitHubInteractiveObject.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ abstract class GitHubInteractiveObject {
2020
GitHubInteractiveObject(GitHub root) {
2121
this.root = root;
2222
}
23+
24+
GitHub getRoot() {
25+
return root;
26+
}
2327
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ private GHAppInstallation getAppInstallationWithToken(String jwtToken) throws IO
8080
.findFirst()
8181
.get();
8282

83-
appInstallation
84-
.setRoot(getGitHubBuilder().withAppInstallationToken(appInstallation.createToken().create().getToken())
85-
.withEndpoint(mockGitHub.apiServer().baseUrl())
86-
.build());
83+
// TODO: this is odd
84+
// appInstallation
85+
// .setRoot(getGitHubBuilder().withAppInstallationToken(appInstallation.createToken().create().getToken())
86+
// .withEndpoint(mockGitHub.apiServer().baseUrl())
87+
// .build());
8788

8889
return appInstallation;
8990
}

0 commit comments

Comments
 (0)