From 4fec8ae9f03093169685e57a6bb6806515f9ec9f Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:27:44 +0530 Subject: [PATCH] Update HttpCodecSpec.scala --- .../scala/zio/http/codec/HttpCodecSpec.scala | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/zio-http/jvm/src/test/scala/zio/http/codec/HttpCodecSpec.scala b/zio-http/jvm/src/test/scala/zio/http/codec/HttpCodecSpec.scala index cf85fab0d9..f4fb155851 100644 --- a/zio-http/jvm/src/test/scala/zio/http/codec/HttpCodecSpec.scala +++ b/zio-http/jvm/src/test/scala/zio/http/codec/HttpCodecSpec.scala @@ -190,15 +190,12 @@ object HttpCodecSpec extends ZIOHttpSpec { val codec = HttpContentCodec.json.only(schema) val data = TestData("ZIO", 42) - val body = codec.encode(data).toOption.get - val decoded = codec - .decodeRequest( - Request( - body = Body.fromChunk(body), - headers = Headers(Header.ContentType(MediaType.application.`json`.fullType)), - ), - ) - .either + val request = Request( + body = body, + headers = Headers(Header.ContentType(MediaType.application.json)), + ) + + val decoded = codec.decodeRequest(request).either assertTrue(decoded == Right(data)) }, @@ -215,11 +212,11 @@ object HttpCodecSpec extends ZIOHttpSpec { val schema = Schema[TestData] val codec = HttpContentCodec.json.only(schema) - val decodeAttempt = codec - .decodeRequest( - headers = Headers(Header.ContentType(MediaType.parseCustomMediaType("application/unsupported").get)), - ) - .either + val request = Request( + headers = Headers(Header.ContentType(MediaType.parseCustomMediaType("application/unsupported").get)), + ) + + val decodeAttempt = codec.decodeRequest(request).either assert(decodeAttempt)(isLeft(isSubtype[IllegalArgumentException](anything))) },