aboutsummaryrefslogtreecommitdiff
path: root/bot/test
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/test
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/test')
-rw-r--r--bot/test/PRServiceTests.scala34
1 files changed, 34 insertions, 0 deletions
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")
+ }
+}