File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
src/test/kotlin/com/haroldadmin/cnradapter Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change @@ -14,8 +14,15 @@ import java.io.IOException
1414
1515internal 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'` () {
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments