Skip to content

Commit b7b342d

Browse files
authored
KTOR-1045 Add MockEngine test for history iteration (#2431)
1 parent 1bd92ea commit b7b342d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import io.ktor.client.*
2+
import io.ktor.client.engine.mock.*
3+
import io.ktor.client.request.*
4+
import io.ktor.http.*
5+
import kotlin.test.*
6+
7+
/*
8+
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
9+
*/
10+
11+
class MockEngineTest {
12+
13+
@Test
14+
fun testHistoryIteration() {
15+
val client = HttpClient(MockEngine) {
16+
engine {
17+
addHandler {
18+
respond("Test")
19+
}
20+
}
21+
}
22+
val engine = client.engine as MockEngine
23+
val count = engine.requestHistory
24+
.map(HttpRequestData::url)
25+
.map(Url::toString)
26+
.count()
27+
28+
assertEquals(0, count)
29+
}
30+
}

0 commit comments

Comments
 (0)