From 8db7bd446d7053f2e16fd14691e0691ee083dea0 Mon Sep 17 00:00:00 2001 From: Lloyd Date: Sat, 10 Mar 2018 19:50:29 +0900 Subject: [PATCH] Make pull request `body` optional (#200) You can create a PR with `"body": null` if you use the API, or use a tool that uses the API. ```shell curl -X GET https://api.github.com/repos/lloydmeta/gh-test-repo/pulls [ { "url": "https://api.github.com/repos/lloydmeta/gh-test-repo/pulls/3", // snip "body": null, // snip }, { "url": "https://api.github.com/repos/lloydmeta/gh-test-repo/pulls/1", "id": 173714694, "html_url": "https://github.com/lloydmeta/gh-test-repo/pull/1", "diff_url": "https://github.com/lloydmeta/gh-test-repo/pull/1.diff", "patch_url": "https://github.com/lloydmeta/gh-test-repo/pull/1.patch", "issue_url": "https://api.github.com/repos/lloydmeta/gh-test-repo/issues/1", // snip "body": "", ] ``` --- .../scala/github4s/free/domain/PullRequest.scala | 2 +- .../github4s/integration/GHPullRequestsSpec.scala | 14 +++++++++++++- .../src/test/scala/github4s/utils/TestData.scala | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/github4s/shared/src/main/scala/github4s/free/domain/PullRequest.scala b/github4s/shared/src/main/scala/github4s/free/domain/PullRequest.scala index d79f1e591..54d5c4484 100644 --- a/github4s/shared/src/main/scala/github4s/free/domain/PullRequest.scala +++ b/github4s/shared/src/main/scala/github4s/free/domain/PullRequest.scala @@ -21,7 +21,7 @@ case class PullRequest( number: Int, state: String, title: String, - body: String, + body: Option[String], locked: Boolean, html_url: String, created_at: String, diff --git a/github4s/shared/src/test/scala/github4s/integration/GHPullRequestsSpec.scala b/github4s/shared/src/test/scala/github4s/integration/GHPullRequestsSpec.scala index c32220722..271bb5725 100644 --- a/github4s/shared/src/test/scala/github4s/integration/GHPullRequestsSpec.scala +++ b/github4s/shared/src/test/scala/github4s/integration/GHPullRequestsSpec.scala @@ -35,6 +35,18 @@ trait GHPullRequestsSpec[T] extends BaseIntegrationSpec[T] { }) } + "PullRequests >> List" should "return a right response when a valid repo is provided but not all pull requests have body" in { + val response = + Github(accessToken).pullRequests + .list("lloydmeta", "gh-test-repo", List(PRFilterOpen)) + .execFuture[T](headerUserAgent) + + testFutureIsRight[List[PullRequest]](response, { r => + r.result.nonEmpty shouldBe true + r.statusCode shouldBe okStatusCode + }) + } + it should "return a non empty list when valid repo and some filters are provided" in { val response = Github(accessToken).pullRequests @@ -73,7 +85,7 @@ trait GHPullRequestsSpec[T] extends BaseIntegrationSpec[T] { "PullRequests >> ListFiles" should "return a right response when a valid repo is provided and not all files have 'patch'" in { val response = - Github(None).pullRequests + Github(accessToken).pullRequests .listFiles("scala", "scala", 4877) .execFuture[T](headerUserAgent) diff --git a/github4s/shared/src/test/scala/github4s/utils/TestData.scala b/github4s/shared/src/test/scala/github4s/utils/TestData.scala index 2601622d5..bb897fe84 100644 --- a/github4s/shared/src/test/scala/github4s/utils/TestData.scala +++ b/github4s/shared/src/test/scala/github4s/utils/TestData.scala @@ -185,7 +185,7 @@ trait TestData extends DummyGithubUrls { number = validPullRequestNumber, state = "open", title = "Title", - body = "Body", + body = Some("Body"), locked = false, html_url = githubApiUrl, created_at = "2011-04-10T20:09:31Z",