Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect request bodies #172

Draft
wants to merge 1 commit into
base: series/0.23
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions servlet/src/test/scala/org/http4s/servlet/ServletIoSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.http4s
package servlet

import cats.effect.IO
import cats.effect.std.Dispatcher
import munit.CatsEffectSuite

import java.io.ByteArrayInputStream
Expand All @@ -33,8 +34,10 @@ class ServletIoSuite extends CatsEffectSuite {
HttpServletRequestStub(inputStream = new TestServletInputStream("test".getBytes(UTF_8)))

val io = NonBlockingServletIo[IO](10)
val body = io.reader(request)
body.compile.toList.map(bytes => new String(bytes.toArray, UTF_8)).assertEquals("test")
Dispatcher.parallel[IO].use { dispatcher =>
val body = io.requestBody(request, dispatcher)
body.compile.to(Array).map(bytes => new String(bytes, UTF_8)).assertEquals("test")
}
}

test(
Expand All @@ -45,8 +48,10 @@ class ServletIoSuite extends CatsEffectSuite {
)

val io = NonBlockingServletIo[IO](10)
val body = io.reader(request)
body.compile.toList.map(bytes => new String(bytes.toArray, UTF_8)).assertEquals("testtesttest")
Dispatcher.parallel[IO].use { dispatcher =>
val body = io.requestBody(request, dispatcher)
body.compile.to(Array).map(bytes => new String(bytes, UTF_8)).assertEquals("testtesttest")
}
}

class TestServletInputStream(body: Array[Byte]) extends ServletInputStream {
Expand Down