Skip to content

Commit 3564023

Browse files
committed
fix: Fix failing tests
1 parent cc82bb3 commit 3564023

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/test/kotlin/com/haroldadmin/cnradapter/ErrorExtractionTest.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ internal class ErrorExtractionTest: AnnotationSpec() {
4747

4848
private class CustomException: Exception()
4949

50-
@Test(expected = CustomException::class)
50+
@Test
5151
fun `extract error from an unknown exception test`() {
5252
val exception = CustomException()
53-
exception.extractNetworkResponse<String, String>(errorConverter)
53+
val response = exception.extractNetworkResponse<String, String>(errorConverter)
54+
with(response) {
55+
shouldBeTypeOf<NetworkResponse.UnknownError>()
56+
this as NetworkResponse.UnknownError
57+
this.error shouldBe exception
58+
}
5459
}
5560
}

src/test/kotlin/com/haroldadmin/cnradapter/NetworkResponseCallTest.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ import java.io.IOException
1414

1515
internal class NetworkResponseCallTest: AnnotationSpec() {
1616
private val errorConverter = Converter<ResponseBody, String> { it.string() }
17-
private val backingCall = CompletableCall<String>()
18-
private val networkResponseCall = NetworkResponseCall<String, String>(backingCall, errorConverter)
17+
18+
private lateinit var backingCall: CompletableCall<String>
19+
private lateinit var networkResponseCall: NetworkResponseCall<String, String>
20+
21+
@Before
22+
fun setup() {
23+
backingCall = CompletableCall<String>()
24+
networkResponseCall = NetworkResponseCall<String, String>(backingCall, errorConverter)
25+
}
1926

2027
@Test(expected = UnsupportedOperationException::class)
2128
fun `should throw an error when invoking 'execute'`() {

src/test/kotlin/com/haroldadmin/cnradapter/SuspendTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ internal class SuspendTest: AnnotationSpec() {
6969
shouldBeTypeOf<NetworkResponse.ServerError<String>>()
7070
this as NetworkResponse.ServerError
7171
code shouldBe responseCode
72-
body shouldBe null
72+
body.isNullOrBlank() shouldBe true
7373
headers!!["TEST"] shouldBe "test"
7474
}
7575
}

0 commit comments

Comments
 (0)