This repository was archived by the owner on Jan 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
main/kotlin/io/kotest/extensions/httpstub
test/kotlin/io/kotest/extensions/httpstub Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,16 @@ class HttpStubber(private val server: WireMockServer) {
46
46
stub(builder, fn)
47
47
}
48
48
49
+ fun head (url : String , fn : RequestStubber .() -> HttpResponse ) {
50
+ val builder = WireMock .head(WireMock .urlEqualTo(url))
51
+ stub(builder, fn)
52
+ }
53
+
54
+ fun options (url : String , fn : RequestStubber .() -> HttpResponse ) {
55
+ val builder = WireMock .options(WireMock .urlEqualTo(url))
56
+ stub(builder, fn)
57
+ }
58
+
49
59
fun put (url : String , fn : RequestStubber .() -> HttpResponse ) {
50
60
val builder = WireMock .put(WireMock .urlEqualTo(url))
51
61
stub(builder, fn)
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import io.ktor.client.HttpClient
7
7
import io.ktor.client.engine.apache.Apache
8
8
import io.ktor.client.request.delete
9
9
import io.ktor.client.request.get
10
+ import io.ktor.client.request.head
11
+ import io.ktor.client.request.options
10
12
import io.ktor.client.request.patch
11
13
import io.ktor.client.request.post
12
14
import io.ktor.client.request.put
@@ -50,6 +52,26 @@ class MethodTest : FunSpec() {
50
52
resp.status shouldBe HttpStatusCode .PartialContent
51
53
}
52
54
55
+ test(" options request" ) {
56
+ server.mappings {
57
+ options(" /foo" ) {
58
+ HttpResponse (HttpStatusCode .Conflict , " hello" )
59
+ }
60
+ }
61
+ val resp = client.options(" http://localhost:${server.port} /foo" )
62
+ resp.status shouldBe HttpStatusCode .Conflict
63
+ }
64
+
65
+ test(" head request" ) {
66
+ server.mappings {
67
+ head(" /foo" ) {
68
+ HttpResponse (HttpStatusCode .MultiStatus , " hello" )
69
+ }
70
+ }
71
+ val resp = client.head(" http://localhost:${server.port} /foo" )
72
+ resp.status shouldBe HttpStatusCode .MultiStatus
73
+ }
74
+
53
75
test(" put request" ) {
54
76
server.mappings {
55
77
put(" /foo" ) {
You can’t perform that action at this time.
0 commit comments