From 2eadadec96d6e7b6b04876e3501a2df206fd39d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Thu, 29 May 2025 10:59:24 +0200 Subject: [PATCH] test(api): Migrate from Kotest to Power Assert --- api/src/commonTest/kotlin/ParametersTest.kt | 45 +++++++++------------ api/src/commonTest/kotlin/PathTest.kt | 10 ++--- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/api/src/commonTest/kotlin/ParametersTest.kt b/api/src/commonTest/kotlin/ParametersTest.kt index d2858f9..2154694 100644 --- a/api/src/commonTest/kotlin/ParametersTest.kt +++ b/api/src/commonTest/kotlin/ParametersTest.kt @@ -1,6 +1,5 @@ package opensavvy.spine.api -import io.kotest.assertions.assertSoftly import io.kotest.assertions.throwables.shouldThrow import io.kotest.matchers.shouldBe import opensavvy.prepared.suite.SuiteDsl @@ -16,10 +15,8 @@ fun SuiteDsl.parameters() = suite("Endpoint parameters") { archived = true } - assertSoftly { - params.archived shouldBe true - shouldThrow { params.private } - } + check(params.archived) + shouldThrow { params.private } params.data shouldBe mapOf( "archived" to "true", @@ -36,10 +33,8 @@ fun SuiteDsl.parameters() = suite("Endpoint parameters") { archived = true } - assertSoftly { - params.archived shouldBe true - params.private shouldBe null - } + check(params.archived == true) + check(params.private == null) params.data shouldBe mapOf( "archived" to "true", @@ -56,8 +51,8 @@ fun SuiteDsl.parameters() = suite("Endpoint parameters") { archived = true } - params.archived shouldBe true - params.private shouldBe false + check(params.archived) + check(!params.private) params.data shouldBe mapOf( "archived" to "true", @@ -100,23 +95,23 @@ fun SuiteDsl.parameters() = suite("Endpoint parameters") { double = 10.0 } - params.string shouldBe "thing" - params.bool shouldBe true + check(params.string == "thing") + check(params.bool) - params.byte shouldBe 1 - params.short shouldBe 2 - params.int shouldBe 3 - params.long shouldBe 4 + check(params.byte == 1.toByte()) + check(params.short == 2.toShort()) + check(params.int == 3) + check(params.long == 4.toLong()) - params.ubyte shouldBe 5u - params.ushort shouldBe 6u - params.uint shouldBe 7u - params.ulong shouldBe 8u + check(params.ubyte == 5.toUByte()) + check(params.ushort == 6.toUShort()) + check(params.uint == 7.toUInt()) + check(params.ulong == 8.toULong()) - params.float shouldBe 9f - params.double shouldBe 10.0 + check(params.float == 9f) + check(params.double == 10.0) - params.data shouldBe mapOf( + check(params.data == mapOf( "string" to "thing", "bool" to "true", @@ -132,6 +127,6 @@ fun SuiteDsl.parameters() = suite("Endpoint parameters") { "float" to "${9.0}", // JVM: "9.0" — JS: "9" "double" to "${10.0}", - ) + )) } } diff --git a/api/src/commonTest/kotlin/PathTest.kt b/api/src/commonTest/kotlin/PathTest.kt index 64a6dca..c78725b 100644 --- a/api/src/commonTest/kotlin/PathTest.kt +++ b/api/src/commonTest/kotlin/PathTest.kt @@ -1,18 +1,16 @@ package opensavvy.spine.api import io.kotest.assertions.throwables.shouldThrow -import io.kotest.assertions.withClue -import io.kotest.matchers.shouldBe import opensavvy.prepared.suite.SuiteDsl -infix fun Addressed.shouldBeAddressedBy(path: String) = withClue("Expecting $this to be addressed by $path") { - this.path.toString() shouldBe path +infix fun Addressed.shouldBeAddressedBy(expectedPath: String) { + check(this.path.toString() == expectedPath) } fun SuiteDsl.paths() = suite("Paths") { test("Valid segments") { - Path.Segment("test").text shouldBe "test" - Path.Segment("test-other2").text shouldBe "test-other2" + check(Path.Segment("test").text == "test") + check(Path.Segment("test-other2").text == "test-other2") } test("A segment shouldn't be empty") { -- knotmirror 0.0.1