Melih Aksoy
03/04/2021, 3:49 PMprocess
.inputStream
.bufferedReader()
.useLines { seq ->
val summary = seq.find { line -> line.contains(KEY_PACKET_LOSS) }
if (summary != null) {
val loss = packetLoss(summary)
val result = when {
loss > acceptablePacketLoss -> Stability.UNSTABLE
loss == MAX_LOSS -> Stability.NO_CONNECTION
else -> Stability.STABLE
}
continuation.resumeIfActive(result)
} else {
continuation.resumeWithExceptionIfActive(
IllegalStateException("Couldn't find result line in ping command")
)
}
}
I added required statics, but bufferedReader
and useLines
are inline methods… can I work this around somehow ?Mattia Tommasone
03/04/2021, 3:55 PMuseLines
to a separate function and testing it separately?
idk if it’s feasible, but it looks like the easiest solution to me, especially since useLines
is inline and, thus, not mockableMelih Aksoy
03/04/2021, 4:00 PMuseLines
but better than skipping due to inline 😄 thanks ! 🙇christophsturm
03/05/2021, 8:30 AM