【发布时间】:2022-01-11 15:25:24
【问题描述】:
在单元测试中验证 akka-stream 源的惯用方法是什么? 我是这样做的:
f.service.fetchData(id).flatMap {
case Right(source) => {
// TODO: I need to validate here that source contains "Test value"
}
case Left(_) => fail("Wrongly responded with error")
}
来源基本上是:
Source.single(ByteString("Test value"))
我尝试通过将 Source 连接到 Sink 并检查发出的值来执行,但断言似乎不起作用。
【问题讨论】:
-
得到它的工作: source .fold("") { case (x, y) => x + y.decodeString("UTF-8") } .runWith(Sink.head) 。等待
标签: scala unit-testing akka-stream