aboutsummaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-02-09 21:54:46 +0100
committerFelix Mulder <felix.mulder@gmail.com>2017-02-13 10:53:45 +0100
commit43f1d800b92241d86703b5518aab171e039fde4e (patch)
tree8bcf88b79312ac5cff3fe5d1504d72af3d2281d2 /bot
parent3f06fe9cc2debaacbb889e33c7339457fc5355cd (diff)
downloaddotty-43f1d800b92241d86703b5518aab171e039fde4e.tar.gz
dotty-43f1d800b92241d86703b5518aab171e039fde4e.tar.bz2
dotty-43f1d800b92241d86703b5518aab171e039fde4e.zip
Add test for unmarshalling github issue form JSON
Diffstat (limited to 'bot')
-rw-r--r--bot/resources/test-pr.json175
-rw-r--r--bot/src/dotty/tools/bot/model/Github.scala15
-rw-r--r--bot/test/PRServiceTests.scala34
3 files changed, 139 insertions, 85 deletions
diff --git a/bot/resources/test-pr.json b/bot/resources/test-pr.json
index 19078ee33..599215f8c 100644
--- a/bot/resources/test-pr.json
+++ b/bot/resources/test-pr.json
@@ -1,56 +1,56 @@
{
- "action": "opened",
- "number": 1943,
+ "action": "synchronize",
+ "number": 1958,
"pull_request": {
- "url": "https://api.github.com/repos/lampepfl/dotty/pulls/1943",
- "id": 104705912,
- "html_url": "https://github.com/lampepfl/dotty/pull/1943",
- "diff_url": "https://github.com/lampepfl/dotty/pull/1943.diff",
- "patch_url": "https://github.com/lampepfl/dotty/pull/1943.patch",
- "issue_url": "https://api.github.com/repos/lampepfl/dotty/issues/1943",
- "number": 1943,
+ "url": "https://api.github.com/repos/lampepfl/dotty/pulls/1958",
+ "id": 105198014,
+ "html_url": "https://github.com/lampepfl/dotty/pull/1958",
+ "diff_url": "https://github.com/lampepfl/dotty/pull/1958.diff",
+ "patch_url": "https://github.com/lampepfl/dotty/pull/1958.patch",
+ "issue_url": "https://api.github.com/repos/lampepfl/dotty/issues/1958",
+ "number": 1958,
"state": "open",
"locked": false,
- "title": "Positioned#initialPos: Union the position of every children",
+ "title": "WIP Add \"enum\" construct",
"user": {
- "login": "smarter",
- "id": 63430,
- "avatar_url": "https://avatars.githubusercontent.com/u/63430?v=3",
+ "login": "odersky",
+ "id": 795990,
+ "avatar_url": "https://avatars.githubusercontent.com/u/795990?v=3",
"gravatar_id": "",
- "url": "https://api.github.com/users/smarter",
- "html_url": "https://github.com/smarter",
- "followers_url": "https://api.github.com/users/smarter/followers",
- "following_url": "https://api.github.com/users/smarter/following{/other_user}",
- "gists_url": "https://api.github.com/users/smarter/gists{/gist_id}",
- "starred_url": "https://api.github.com/users/smarter/starred{/owner}{/repo}",
- "subscriptions_url": "https://api.github.com/users/smarter/subscriptions",
- "organizations_url": "https://api.github.com/users/smarter/orgs",
- "repos_url": "https://api.github.com/users/smarter/repos",
- "events_url": "https://api.github.com/users/smarter/events{/privacy}",
- "received_events_url": "https://api.github.com/users/smarter/received_events",
+ "url": "https://api.github.com/users/odersky",
+ "html_url": "https://github.com/odersky",
+ "followers_url": "https://api.github.com/users/odersky/followers",
+ "following_url": "https://api.github.com/users/odersky/following{/other_user}",
+ "gists_url": "https://api.github.com/users/odersky/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/odersky/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/odersky/subscriptions",
+ "organizations_url": "https://api.github.com/users/odersky/orgs",
+ "repos_url": "https://api.github.com/users/odersky/repos",
+ "events_url": "https://api.github.com/users/odersky/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/odersky/received_events",
"type": "User",
"site_admin": false
},
- "body": "Previously we missed some children, one consequence of this is that the\r\nposition of the typed tree corresponding to the lambda \"z => 1\" did not\r\ncontain the position of \"z\".\r\n\r\nReview by @odersky ",
- "created_at": "2017-02-05T16:51:01Z",
- "updated_at": "2017-02-05T16:51:01Z",
+ "body": "This is a prototype implementation to add an \"enum\" construct to Scala. Scala enums give a more concise notation for \r\n\r\n - enums as in Java\r\n - ADTs\r\n - GADTs\r\n\r\nCurrent status\r\n\r\n - [x] First implementation\r\n - [x] Some test cases\r\n - [ ] A specification\r\n - [ ] An implementation of generic programming in the style of SYB. We need to clarify first exactly\r\n what we want from the compiler\r\n - [ ] A decision whether we want to go ahead with this",
+ "created_at": "2017-02-08T11:29:18Z",
+ "updated_at": "2017-02-09T09:18:27Z",
"closed_at": null,
"merged_at": null,
- "merge_commit_sha": null,
+ "merge_commit_sha": "7100d31c76a0317b8cd3445970c463b133215252",
"assignee": null,
"assignees": [
],
"milestone": null,
- "commits_url": "https://api.github.com/repos/lampepfl/dotty/pulls/1943/commits",
- "review_comments_url": "https://api.github.com/repos/lampepfl/dotty/pulls/1943/comments",
+ "commits_url": "https://api.github.com/repos/lampepfl/dotty/pulls/1958/commits",
+ "review_comments_url": "https://api.github.com/repos/lampepfl/dotty/pulls/1958/comments",
"review_comment_url": "https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}",
- "comments_url": "https://api.github.com/repos/lampepfl/dotty/issues/1943/comments",
- "statuses_url": "https://api.github.com/repos/lampepfl/dotty/statuses/9e9206dbf3e1cbd378adcb9f65637d2cf331cc10",
+ "comments_url": "https://api.github.com/repos/lampepfl/dotty/issues/1958/comments",
+ "statuses_url": "https://api.github.com/repos/lampepfl/dotty/statuses/ce4051743d590721dc969c92c44a35147e1e3abc",
"head": {
- "label": "dotty-staging:fix/lambda-position",
- "ref": "fix/lambda-position",
- "sha": "9e9206dbf3e1cbd378adcb9f65637d2cf331cc10",
+ "label": "dotty-staging:add-enum",
+ "ref": "add-enum",
+ "sha": "ce4051743d590721dc969c92c44a35147e1e3abc",
"user": {
"login": "dotty-staging",
"id": 6998674,
@@ -136,13 +136,13 @@
"deployments_url": "https://api.github.com/repos/dotty-staging/dotty/deployments",
"created_at": "2014-03-19T13:06:15Z",
"updated_at": "2016-07-11T14:41:18Z",
- "pushed_at": "2017-02-05T16:50:41Z",
+ "pushed_at": "2017-02-09T09:18:27Z",
"git_url": "git://github.com/dotty-staging/dotty.git",
"ssh_url": "git@github.com:dotty-staging/dotty.git",
"clone_url": "https://github.com/dotty-staging/dotty.git",
"svn_url": "https://github.com/dotty-staging/dotty",
"homepage": "",
- "size": 27650,
+ "size": 27676,
"stargazers_count": 4,
"watchers_count": 4,
"language": "Scala",
@@ -162,7 +162,7 @@
"base": {
"label": "lampepfl:master",
"ref": "master",
- "sha": "da7d7231b7f21fe1085abc569eb783590074a359",
+ "sha": "75bea8dccce2bc3c0e8298ee71061c9871fd26ac",
"user": {
"login": "lampepfl",
"id": 2684793,
@@ -247,68 +247,73 @@
"releases_url": "https://api.github.com/repos/lampepfl/dotty/releases{/id}",
"deployments_url": "https://api.github.com/repos/lampepfl/dotty/deployments",
"created_at": "2012-12-06T12:57:33Z",
- "updated_at": "2017-02-05T01:04:39Z",
- "pushed_at": "2017-02-05T16:50:21Z",
+ "updated_at": "2017-02-08T13:10:05Z",
+ "pushed_at": "2017-02-09T08:51:58Z",
"git_url": "git://github.com/lampepfl/dotty.git",
"ssh_url": "git@github.com:lampepfl/dotty.git",
"clone_url": "https://github.com/lampepfl/dotty.git",
"svn_url": "https://github.com/lampepfl/dotty",
"homepage": "http://dotty.epfl.ch",
- "size": 28511,
- "stargazers_count": 1447,
- "watchers_count": 1447,
+ "size": 28896,
+ "stargazers_count": 1452,
+ "watchers_count": 1452,
"language": "Scala",
"has_issues": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": true,
- "forks_count": 212,
+ "forks_count": 213,
"mirror_url": null,
- "open_issues_count": 243,
- "forks": 212,
- "open_issues": 243,
- "watchers": 1447,
+ "open_issues_count": 250,
+ "forks": 213,
+ "open_issues": 250,
+ "watchers": 1452,
"default_branch": "master"
}
},
"_links": {
"self": {
- "href": "https://api.github.com/repos/lampepfl/dotty/pulls/1943"
+ "href": "https://api.github.com/repos/lampepfl/dotty/pulls/1958"
},
"html": {
- "href": "https://github.com/lampepfl/dotty/pull/1943"
+ "href": "https://github.com/lampepfl/dotty/pull/1958"
},
"issue": {
- "href": "https://api.github.com/repos/lampepfl/dotty/issues/1943"
+ "href": "https://api.github.com/repos/lampepfl/dotty/issues/1958"
},
"comments": {
- "href": "https://api.github.com/repos/lampepfl/dotty/issues/1943/comments"
+ "href": "https://api.github.com/repos/lampepfl/dotty/issues/1958/comments"
},
"review_comments": {
- "href": "https://api.github.com/repos/lampepfl/dotty/pulls/1943/comments"
+ "href": "https://api.github.com/repos/lampepfl/dotty/pulls/1958/comments"
},
"review_comment": {
"href": "https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}"
},
"commits": {
- "href": "https://api.github.com/repos/lampepfl/dotty/pulls/1943/commits"
+ "href": "https://api.github.com/repos/lampepfl/dotty/pulls/1958/commits"
},
"statuses": {
- "href": "https://api.github.com/repos/lampepfl/dotty/statuses/9e9206dbf3e1cbd378adcb9f65637d2cf331cc10"
+ "href": "https://api.github.com/repos/lampepfl/dotty/statuses/ce4051743d590721dc969c92c44a35147e1e3abc"
}
},
+ "requested_reviewers": [
+
+ ],
"merged": false,
"mergeable": null,
"mergeable_state": "unknown",
"merged_by": null,
- "comments": 0,
- "review_comments": 0,
+ "comments": 1,
+ "review_comments": 2,
"maintainer_can_modify": true,
- "commits": 1,
- "additions": 2,
- "deletions": 0,
- "changed_files": 1
+ "commits": 13,
+ "additions": 501,
+ "deletions": 173,
+ "changed_files": 29
},
+ "before": "a51a963005eb6f5a42a0cef7420a7008956e622a",
+ "after": "ce4051743d590721dc969c92c44a35147e1e3abc",
"repository": {
"id": 7035651,
"name": "dotty",
@@ -374,27 +379,27 @@
"releases_url": "https://api.github.com/repos/lampepfl/dotty/releases{/id}",
"deployments_url": "https://api.github.com/repos/lampepfl/dotty/deployments",
"created_at": "2012-12-06T12:57:33Z",
- "updated_at": "2017-02-05T01:04:39Z",
- "pushed_at": "2017-02-05T16:50:21Z",
+ "updated_at": "2017-02-08T13:10:05Z",
+ "pushed_at": "2017-02-09T08:51:58Z",
"git_url": "git://github.com/lampepfl/dotty.git",
"ssh_url": "git@github.com:lampepfl/dotty.git",
"clone_url": "https://github.com/lampepfl/dotty.git",
"svn_url": "https://github.com/lampepfl/dotty",
"homepage": "http://dotty.epfl.ch",
- "size": 28511,
- "stargazers_count": 1447,
- "watchers_count": 1447,
+ "size": 28896,
+ "stargazers_count": 1452,
+ "watchers_count": 1452,
"language": "Scala",
"has_issues": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": true,
- "forks_count": 212,
+ "forks_count": 213,
"mirror_url": null,
- "open_issues_count": 243,
- "forks": 212,
- "open_issues": 243,
- "watchers": 1447,
+ "open_issues_count": 250,
+ "forks": 213,
+ "open_issues": 250,
+ "watchers": 1452,
"default_branch": "master"
},
"organization": {
@@ -411,21 +416,21 @@
"description": null
},
"sender": {
- "login": "smarter",
- "id": 63430,
- "avatar_url": "https://avatars.githubusercontent.com/u/63430?v=3",
+ "login": "felixmulder",
+ "id": 1530049,
+ "avatar_url": "https://avatars.githubusercontent.com/u/1530049?v=3",
"gravatar_id": "",
- "url": "https://api.github.com/users/smarter",
- "html_url": "https://github.com/smarter",
- "followers_url": "https://api.github.com/users/smarter/followers",
- "following_url": "https://api.github.com/users/smarter/following{/other_user}",
- "gists_url": "https://api.github.com/users/smarter/gists{/gist_id}",
- "starred_url": "https://api.github.com/users/smarter/starred{/owner}{/repo}",
- "subscriptions_url": "https://api.github.com/users/smarter/subscriptions",
- "organizations_url": "https://api.github.com/users/smarter/orgs",
- "repos_url": "https://api.github.com/users/smarter/repos",
- "events_url": "https://api.github.com/users/smarter/events{/privacy}",
- "received_events_url": "https://api.github.com/users/smarter/received_events",
+ "url": "https://api.github.com/users/felixmulder",
+ "html_url": "https://github.com/felixmulder",
+ "followers_url": "https://api.github.com/users/felixmulder/followers",
+ "following_url": "https://api.github.com/users/felixmulder/following{/other_user}",
+ "gists_url": "https://api.github.com/users/felixmulder/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/felixmulder/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/felixmulder/subscriptions",
+ "organizations_url": "https://api.github.com/users/felixmulder/orgs",
+ "repos_url": "https://api.github.com/users/felixmulder/repos",
+ "events_url": "https://api.github.com/users/felixmulder/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/felixmulder/received_events",
"type": "User",
"site_admin": false
}
diff --git a/bot/src/dotty/tools/bot/model/Github.scala b/bot/src/dotty/tools/bot/model/Github.scala
new file mode 100644
index 000000000..c089f0cf2
--- /dev/null
+++ b/bot/src/dotty/tools/bot/model/Github.scala
@@ -0,0 +1,15 @@
+package dotty.tools.bot
+package model
+
+object Github {
+ case class PullRequest(
+ url: String,
+ id: Long,
+ commits_url: String
+ )
+
+ case class Issue(
+ number: Int,
+ pull_request: Option[PullRequest]
+ )
+}
diff --git a/bot/test/PRServiceTests.scala b/bot/test/PRServiceTests.scala
new file mode 100644
index 000000000..a8fdba6e2
--- /dev/null
+++ b/bot/test/PRServiceTests.scala
@@ -0,0 +1,34 @@
+package dotty.tools.bot
+
+import org.junit.Assert._
+import org.junit.Test
+
+import io.circe._
+import io.circe.generic.auto._
+import io.circe.syntax._
+import io.circe.parser.decode
+
+import model.Github._
+import org.http4s.client.blaze._
+import scalaz.concurrent.Task
+
+class PRServiceTests extends PullRequestService {
+ val user = sys.env("USER")
+ val token = sys.env("TOKEN")
+
+ def getResource(r: String): String =
+ Option(getClass.getResourceAsStream(r)).map(scala.io.Source.fromInputStream)
+ .map(_.mkString)
+ .getOrElse(throw new Exception(s"resource not found: $r"))
+
+
+ @Test def canUnmarshalIssueJson = {
+ val json = getResource("/test-pr.json")
+ val issue: Issue = decode[Issue](json) match {
+ case Right(is: Issue) => is
+ case Left(ex) => throw ex
+ }
+
+ assert(issue.pull_request.isDefined, "missing pull request")
+ }
+}