Skip to content

Commit

Permalink
Add test for issue with List of Commits returning 404.
Browse files Browse the repository at this point in the history
  • Loading branch information
NlightNFotis committed Jan 10, 2024
1 parent 477745a commit a7c4132
Show file tree
Hide file tree
Showing 41 changed files with 34,663 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/test/java/org/kohsuke/github/GHPullRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ public void pullRequestComment() throws Exception {
assertThat(comments, contains(hasProperty("body", equalTo("Second comment"))));
}

/**
* Get list of commits from searched PR.
*
* This would result in a wrong API URL used, resulting in a GHFileNotFoundException.
*
* For more details, please have a look at the bug description in https://github.com/hub4j/github-api/issues/1778.
*
* @throws Exception
* the exception
*/
@Test
public void getListOfCommits() throws Exception {
String name = "getListOfCommits";
GHPullRequestSearchBuilder builder = getRepository().searchPullRequests().isClosed();
Optional<GHPullRequest> firstPR = builder.list().toList().stream().findFirst();

try {
String val = firstPR.get().listCommits().toArray()[0].getApiUrl().toString();
assertThat(val, notNullValue());
} catch (GHFileNotFoundException e) {
if (e.getMessage().contains("/issues/")) {
fail("Issued a request against the wrong path");
}
}
}

/**
* Close pull request.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"login": "NlightNFotis",
"id": 1859274,
"node_id": "MDQ6VXNlcjE4NTkyNzQ=",
"avatar_url": "https://avatars.githubusercontent.com/u/1859274?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/NlightNFotis",
"html_url": "https://github.com/NlightNFotis",
"followers_url": "https://api.github.com/users/NlightNFotis/followers",
"following_url": "https://api.github.com/users/NlightNFotis/following{/other_user}",
"gists_url": "https://api.github.com/users/NlightNFotis/gists{/gist_id}",
"starred_url": "https://api.github.com/users/NlightNFotis/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/NlightNFotis/subscriptions",
"organizations_url": "https://api.github.com/users/NlightNFotis/orgs",
"repos_url": "https://api.github.com/users/NlightNFotis/repos",
"events_url": "https://api.github.com/users/NlightNFotis/events{/privacy}",
"received_events_url": "https://api.github.com/users/NlightNFotis/received_events",
"type": "User",
"site_admin": false,
"name": "Fotis Koutoulakis",
"company": "@diffblue ",
"blog": "https://nlightnfotis.github.io",
"location": "Oxford, United Kingdom",
"email": "fotis.koutoulakis@gmail.com",
"hireable": null,
"bio": "Interests in Mathematics, Computer Science, Biology and Economics.",
"twitter_username": "NlightNFotis",
"public_repos": 27,
"public_gists": 8,
"followers": 38,
"following": 51,
"created_at": "2012-06-17T17:34:11Z",
"updated_at": "2023-09-18T09:30:51Z"
}
Loading

0 comments on commit a7c4132

Please sign in to comment.