Last active
October 4, 2015 10:29
-
-
Save maowug/e15a6b0a2a7ef31d00b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment