Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
noelwelsh committed Jul 18, 2024
1 parent 2017afe commit cabe04f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/jvm/src/test/scala/krop/route/PathUnparseSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PathUnparseSuite extends FunSuite {
)
}

test("Non-capturing all path unparses to expected Uri"){
test("Non-capturing all path unparses to expected Uri") {
assertEquals(
nonCapturingAllPath.unparse(EmptyTuple),
Uri(path = (Uri.Path.Root / "assets" / "html").addEndsWithSlash)
Expand Down
43 changes: 28 additions & 15 deletions core/jvm/src/test/scala/krop/route/RequestEntitySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import munit.CatsEffectSuite
import org.http4s.Method
import org.http4s.Uri
import org.http4s.implicits.*
import org.http4s.{Request as Http4sRequest}
import org.http4s.{Entity as Http4sEntity}
import org.http4s.{Request as Http4sRequest}

class RequestEntitySuite extends CatsEffectSuite {
val unitRequest = Request.get(Path.root).withEntity(Entity.unit)
Expand All @@ -32,12 +32,15 @@ class RequestEntitySuite extends CatsEffectSuite {
val request =
Http4sRequest(method = Method.GET, uri = uri"http://example.org/")

unitRequest.parse(request)(using Raise.toOption).map(opt =>
opt match {
case Some(Tuple1(())) => true
case other => fail(s"Not the expected entity: $other")
}
).assert
unitRequest
.parse(request)(using Raise.toOption)
.map(opt =>
opt match {
case Some(Tuple1(())) => true
case other => fail(s"Not the expected entity: $other")
}
)
.assert
}

test("Unit request unparses unit") {
Expand All @@ -54,19 +57,29 @@ class RequestEntitySuite extends CatsEffectSuite {

test("Text request parses string") {
val request =
Http4sRequest(method = Method.GET, uri = uri"http://example.org/", entity = Http4sEntity.utf8String("hello"))
Http4sRequest(
method = Method.GET,
uri = uri"http://example.org/",
entity = Http4sEntity.utf8String("hello")
)

textRequest.parse(request)(using Raise.toOption).map(opt =>
opt match {
case Some(Tuple1("hello")) => true
case other => fail(s"Not the expected entity: $other")
}
)
textRequest
.parse(request)(using Raise.toOption)
.map(opt =>
opt match {
case Some(Tuple1("hello")) => true
case other => fail(s"Not the expected entity: $other")
}
)
}

test("Text request unparses text") {
val request =
Http4sRequest(method = Method.GET, uri = uri"http://example.org/", entity = Http4sEntity.utf8String("hello"))
Http4sRequest(
method = Method.GET,
uri = uri"http://example.org/",
entity = Http4sEntity.utf8String("hello")
)

val unparsed = textRequest.unparse(Tuple1("hello"))

Expand Down
6 changes: 4 additions & 2 deletions core/jvm/src/test/scala/krop/route/RequestHeaderSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class RequestHeaderSuite extends CatsEffectSuite {
val extractContentTypeWithDefaultRequest =
Request.get(Path.root).extractHeader(jsonContentType)


test("Ensure header fails if header does not exist") {
val request =
Http4sRequest(method = Method.GET, uri = uri"http://example.org/")

ensureJsonHeaderRequest.parse(request)(using Raise.toOption).map(_.isEmpty).assert
ensureJsonHeaderRequest
.parse(request)(using Raise.toOption)
.map(_.isEmpty)
.assert
}

test("Ensure header succeeds if header does exist") {
Expand Down

0 comments on commit cabe04f

Please sign in to comment.