-
Notifications
You must be signed in to change notification settings - Fork 3
/
EShopProductReturnProductTest.kt
34 lines (29 loc) · 1.27 KB
/
EShopProductReturnProductTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package io.github.servb.eShop.product.route.singleOperation
import io.github.servb.eShop.product.inMemoryEShopProduct
import io.github.servb.eShop.util.parse
import io.github.servb.eShop.util.withTestApplication
import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.maps.shouldContainExactly
import io.kotest.matchers.shouldBe
import io.ktor.application.Application
import io.ktor.http.HttpMethod
import io.ktor.http.HttpStatusCode
import io.ktor.server.testing.handleRequest
class EShopProductReturnProductTest : BehaviorSpec({
given("in-memory e-shop") {
withTestApplication(Application::inMemoryEShopProduct) {
`when`("I call GET nonexistent /v1/product") {
val call = handleRequest(HttpMethod.Get, "/v1/product/2")
then("the response status should be NotFound") {
call.response.status() shouldBe HttpStatusCode.NotFound
}
and("I decode the response body") {
val responseMap: Map<String, Any?> = call.response.content.parse()
then("it should have only proper 'data' field") {
responseMap shouldContainExactly mapOf("data" to null)
}
}
}
}
}
})