Skip to content

Commit

Permalink
Adjust error handling test to http4s
Browse files Browse the repository at this point in the history
  • Loading branch information
kciesielski committed Mar 26, 2024
1 parent b57ecff commit 8229f8a
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import sttp.tapir.server.tests.ServerMetricsTest._
import sttp.tapir.tests.Test
import sttp.tapir.tests.data.Fruit
import sttp.ws.{WebSocket, WebSocketFrame}

import scala.concurrent.duration._

abstract class ServerWebSocketTests[F[_], S <: Streams[S], OPTIONS, ROUTE](
Expand Down Expand Up @@ -144,11 +145,13 @@ abstract class ServerWebSocketTests[F[_], S <: Streams[S], OPTIONS, ROUTE](
})
.get(baseUri.scheme("ws"))
.send(backend)
.map(
_.body.map(_.map(_.left.map(_.statusCode))) shouldBe Right(
List(Right("echo: test1"), Right("echo: test2"), Left(1011))
)
)
.map { r =>
val results = r.body.map(_.map(_.left.map(_.statusCode))).value
results.take(2) shouldBe
List(Right("echo: test1"), Right("echo: test2"))
val closeCode = results.last.left.value
assert(closeCode == 1000 || closeCode == 1011) // some servers respond with Close(normal), some with Close(error)
}
},
testServer(
endpoint.out(
Expand Down

0 comments on commit 8229f8a

Please sign in to comment.