u.go
2015-10-04T10:29:06Z

toFuture.scala

| /**
| * queryStringをFakeRequestに入れるユーティリティ
| * FakeRequest().copy(queryString = qs)にすると、戻り値が
| * Iteratee[Array[Byte], Result] となるため、これを Future[B] へ fold します
| *
| * //usage:
| * // val actual = controller.purchase()(FakeRequest().copy(
| * // queryString = validBuyingRequestParams)) fold toFuture
| */
| def toFuture[B](step: Step[Array[Byte], B]): Future[B] = step match {
| case Step.Done(a0, e) => Future(a0)
| case Step.Cont(k) => k(Input.EOF) fold {
| case Step.Done(a1, _) => Future.successful(a1)
| case _ => throw new Exception("error or diverging iteratee")
| }
| case Step.Error(msg, e) => throw new Exception("error iteratee")
| }