From e5ebd242a4cb982af6b01ec1976ecfc91398189f Mon Sep 17 00:00:00 2001 From: adamw Date: Fri, 21 Jul 2017 16:40:07 +0200 Subject: Scalaz version of the async http client handler, wrapping responses in a Task --- tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala | 9 ++++++--- tests/src/test/scala/com/softwaremill/sttp/testHelpers.scala | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'tests/src/test/scala/com/softwaremill') diff --git a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala index 96fbbae..f456fb1 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala @@ -16,7 +16,8 @@ import com.typesafe.scalalogging.StrictLogging import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures} import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers} import better.files._ -import com.softwaremill.sttp.asynchttpclient.AsyncHttpClientHandler +import com.softwaremill.sttp.asynchttpclient.future.FutureAsyncHttpClientHandler +import com.softwaremill.sttp.asynchttpclient.scalaz.ScalazAsyncHttpClientHandler import scala.language.higherKinds @@ -117,8 +118,10 @@ class BasicTests ForceWrappedValue.id) runTests("Akka HTTP")(new AkkaHttpSttpHandler(actorSystem), ForceWrappedValue.future) - runTests("Async Http Client")(new AsyncHttpClientHandler(), - ForceWrappedValue.future) + runTests("Async Http Client - Future")(new FutureAsyncHttpClientHandler(), + ForceWrappedValue.future) + runTests("Async Http Client - Scalaz")(new ScalazAsyncHttpClientHandler(), + ForceWrappedValue.scalazTask) def runTests[R[_]](name: String)( implicit handler: SttpHandler[R, Nothing], diff --git a/tests/src/test/scala/com/softwaremill/sttp/testHelpers.scala b/tests/src/test/scala/com/softwaremill/sttp/testHelpers.scala index 6d83848..9114d8b 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/testHelpers.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/testHelpers.scala @@ -9,6 +9,7 @@ import org.scalatest.concurrent.ScalaFutures import scala.concurrent.Future import scala.language.higherKinds +import scalaz.concurrent.Task trait TestHttpServer extends BeforeAndAfterAll with ScalaFutures { this: Suite => @@ -43,6 +44,10 @@ trait ForceWrapped extends ScalaFutures { this: Suite => override def force[T](wrapped: Future[T]): T = wrapped.futureValue } + val scalazTask = new ForceWrappedValue[Task] { + override def force[T](wrapped: Task[T]): T = + wrapped.unsafePerformSync + } } implicit class ForceDecorator[R[_], T](wrapped: R[T]) { def force()(implicit fwv: ForceWrappedValue[R]): T = fwv.force(wrapped) -- cgit v1.2.3