单元测试 - 存根或嘲弄finagle客户端

时间:2016-06-09 22:44:16

标签: unit-testing finagle twitter-finagle

以下是我想对不同的http响应代码进行单元测试的几行代码。其中一个是代码201。请指教

val cb = ClientBuilder()
val myClient = cb.build()
val req =
      RequestBuilder()
        .url(loginUrl)
        .setHeader("Content-Type", "application/json")
        .buildPost(copiedBuffer(body.getBytes(UTF_8)))

myClient(req).map(http.Response(_)).flatMap { response =>
      response.statusCode match {
        case 201 => //parse response
        case _ =>
          println(" some reseponse")
          Future(proxy(response))
       }
}

0 个答案:

没有答案