Skip to content

Commit

Permalink
Make sure we return an empty list when no reviews
Browse files Browse the repository at this point in the history
I couldn't reproduce the problem described in hub4j#1768 but I thought we
could add a test anyway as it doesn't cost us much.
  • Loading branch information
gsmet committed Mar 9, 2024
1 parent 22d4154 commit 9bd83fb
Show file tree
Hide file tree
Showing 44 changed files with 1,032 additions and 2,077 deletions.
6 changes: 5 additions & 1 deletion src/test/java/org/kohsuke/github/GHPullRequestTest.java
Expand Up @@ -231,14 +231,18 @@ public void closePullRequest() throws Exception {
public void pullRequestReviews() throws Exception {
String name = "testPullRequestReviews";
GHPullRequest p = getRepository().createPullRequest(name, "test/stable", "main", "## test");

List<GHPullRequestReview> reviews = p.listReviews().toList();
assertThat(reviews.size(), is(0));

GHPullRequestReview draftReview = p.createReview()
.body("Some draft review")
.comment("Some niggle", "README.md", 1)
.create();
assertThat(draftReview.getState(), is(GHPullRequestReviewState.PENDING));
assertThat(draftReview.getBody(), is("Some draft review"));
assertThat(draftReview.getCommitId(), notNullValue());
List<GHPullRequestReview> reviews = p.listReviews().toList();
reviews = p.listReviews().toList();
assertThat(reviews.size(), is(1));
GHPullRequestReview review = reviews.get(0);
assertThat(review.getState(), is(GHPullRequestReviewState.PENDING));
Expand Down
@@ -0,0 +1,66 @@
{
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"url": "https://api.github.com/orgs/hub4j-test-org",
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
"description": "Hub4j Test Org Description (this could be null or blank too)",
"name": "Hub4j Test Org Name (this could be null or blank too)",
"company": null,
"blog": "https://hub4j.url.io/could/be/null",
"location": "Hub4j Test Org Location (this could be null or blank too)",
"email": "hub4jtestorgemail@could.be.null.com",
"twitter_username": null,
"is_verified": false,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 26,
"public_gists": 0,
"followers": 2,
"following": 0,
"html_url": "https://github.com/hub4j-test-org",
"created_at": "2014-05-10T19:39:11Z",
"updated_at": "2020-06-04T05:56:10Z",
"archived_at": null,
"type": "Organization",
"total_private_repos": 6,
"owned_private_repos": 6,
"private_gists": 0,
"disk_usage": 12014,
"collaborators": 1,
"billing_email": "kk@kohsuke.org",
"default_repository_permission": "none",
"members_can_create_repositories": false,
"two_factor_requirement_enabled": false,
"members_allowed_repository_creation_type": "none",
"members_can_create_public_repositories": false,
"members_can_create_private_repositories": false,
"members_can_create_internal_repositories": false,
"members_can_create_pages": true,
"members_can_fork_private_repositories": false,
"web_commit_signoff_required": false,
"members_can_create_public_pages": true,
"members_can_create_private_pages": true,
"plan": {
"name": "free",
"space": 976562499,
"private_repos": 10000,
"filled_seats": 50,
"seats": 3
},
"advanced_security_enabled_for_new_repositories": false,
"dependabot_alerts_enabled_for_new_repositories": false,
"dependabot_security_updates_enabled_for_new_repositories": false,
"dependency_graph_enabled_for_new_repositories": false,
"secret_scanning_enabled_for_new_repositories": false,
"secret_scanning_push_protection_enabled_for_new_repositories": false,
"secret_scanning_push_protection_custom_link_enabled": false,
"secret_scanning_push_protection_custom_link": null,
"secret_scanning_validity_checks_enabled": false
}

This file was deleted.

This file was deleted.

@@ -0,0 +1,38 @@
{
"id": 1926195021,
"node_id": "PRR_kwDODFTdCc5yz2dN",
"user": {
"login": "gsmet",
"id": 1279749,
"node_id": "MDQ6VXNlcjEyNzk3NDk=",
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?u=e462a6165ea17647aed446ca31fae604338ae18c&v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gsmet",
"html_url": "https://github.com/gsmet",
"followers_url": "https://api.github.com/users/gsmet/followers",
"following_url": "https://api.github.com/users/gsmet/following{/other_user}",
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
"organizations_url": "https://api.github.com/users/gsmet/orgs",
"repos_url": "https://api.github.com/users/gsmet/repos",
"events_url": "https://api.github.com/users/gsmet/events{/privacy}",
"received_events_url": "https://api.github.com/users/gsmet/received_events",
"type": "User",
"site_admin": false
},
"body": "Some new review",
"state": "PENDING",
"html_url": "https://github.com/hub4j-test-org/github-api/pull/475#pullrequestreview-1926195021",
"pull_request_url": "https://api.github.com/repos/hub4j-test-org/github-api/pulls/475",
"author_association": "MEMBER",
"_links": {
"html": {
"href": "https://github.com/hub4j-test-org/github-api/pull/475#pullrequestreview-1926195021"
},
"pull_request": {
"href": "https://api.github.com/repos/hub4j-test-org/github-api/pulls/475"
}
},
"commit_id": "07374fe73aff1c2024a8d4114b32406c7a8e89b7"
}

0 comments on commit 9bd83fb

Please sign in to comment.