Skip to content

Commit

Permalink
temporarily remove Kotest matcher due to bug in Kotest with equality …
Browse files Browse the repository at this point in the history
…matching. kotest/kotest#1727
  • Loading branch information
daviddenton committed Sep 27, 2020
1 parent 732b919 commit 30cc45e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ changes with their rationale when appropriate:

### v3.262.0 (uncut)
- **http4k-*** : Upgrade some dependency versions.
- **http4k-testing-kotest - Possible Break (on Jackosn)**: Remove a `haveBody` matcher which uses `Matcher<JsonNode>` directly, because of a bug in Kotest:
https://github.com/kotest/kotest/issues/1727

### v3.261.0
- **http4k-*** : Upgrade some dependency versions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ fun <T : HttpMessage, B> haveBody(lens: BodyLens<B>, matcher: Matcher<B>): Match

fun <NODE> Json<NODE>.haveBody(expected: NODE): Matcher<HttpMessage> = httpMessageHas("Body", { m: HttpMessage -> compact(parse(m.bodyString())) }, be(compact(expected)))

fun <NODE> Json<NODE>.haveBody(expected: Matcher<NODE>): Matcher<HttpMessage> = httpMessageHas("Body", { m: HttpMessage -> parse(m.bodyString()) }, expected)
// Removed because of : https://github.com/kotest/kotest/issues/1727
//fun <NODE> Json<NODE>.haveBody(expected: Matcher<NODE>): Matcher<HttpMessage> = httpMessageHas("Body", { m: HttpMessage -> parse(m.bodyString()) }, expected)

fun <NODE> Json<NODE>.haveBody(expected: String): Matcher<HttpMessage> = httpMessageHas("Body", { m: HttpMessage -> compactify(m.bodyString()) }, be(compactify(expected)))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.http4k.core.with
import org.http4k.format.Jackson
import org.http4k.lens.Header
import org.http4k.lens.string
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test

class HttpMessageMatchersTest {
Expand All @@ -31,7 +30,7 @@ class HttpMessageMatchersTest {
fun `header no value`() = assertMatchAndNonMatch(Request(GET, "/").header("header", "bob").header("header", "bob2"), haveHeader("header"), haveHeader("header").invert())

@Test
fun `header - non-nullable string matcher`() = assertMatchAndNonMatch(Request(GET, "/").header("header", "bob").header("header", "bob2"), haveHeader("header", contain("bob")), haveHeader("header", be<String>("bill")))
fun `header - non-nullable string matcher`() = assertMatchAndNonMatch(Request(GET, "/").header("header", "bob").header("header", "bob2"), haveHeader("header", contain("bob")), haveHeader("header", be("bill")))

@Test
fun `header lens`() =
Expand Down Expand Up @@ -64,9 +63,9 @@ class HttpMessageMatchersTest {
@Test
fun `json body matcher`() = assertMatchAndNonMatch(Request(GET, "/").body("""{"hello":"world"}"""), Jackson.haveBody("""{"hello":"world"}"""), Jackson.haveBody("""{"hello":"w2orld"}"""))

@Test
@Disabled("some problem with jackson")
fun `json node body matcher`() = assertMatchAndNonMatch(Request(GET, "/").body("""{"hello":"world"}"""), Jackson.haveBody(be(Jackson.obj("hello" to Jackson.string("world")))), Jackson.haveBody(be(Jackson.obj("hello" to Jackson.string("wo2rld")))))
// @Test
// @Disabled("https://github.com/kotest/kotest/issues/1727")
// fun `json node body matcher`() = assertMatchAndNonMatch(Request(GET, "/").body("""{"hello":"world"}"""), Jackson.haveBody(be(Jackson.obj("hello" to Jackson.string("world")))), Jackson.haveBody(be(Jackson.obj("hello" to Jackson.string("wo2rld")))))

@Test
fun `json node body equal matcher`() = assertMatchAndNonMatch(Request(GET, "/").body("""{"hello":"world"}"""), Jackson.haveBody(Jackson.obj("hello" to Jackson.string("world"))), Jackson.haveBody(Jackson.obj("hello" to Jackson.string("wo2rld"))))
Expand Down

0 comments on commit 30cc45e

Please sign in to comment.