Skip to content

Commit 2a9a1aa

Browse files
committed
fix: Cleanup casts and unused code
1 parent d9912f3 commit 2a9a1aa

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/main/kotlin/com/haroldadmin/cnradapter/NetworkResponse.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ sealed class NetworkResponse<out T : Any, out U : Any> {
1313
val code: Int
1414
) : NetworkResponse<T, Nothing>()
1515

16-
fun wasSuccessful(): Boolean = this is Success
17-
1816
/**
1917
* Describe an error without a specific type.
2018
* Makes it easier to deal with the case where you just want to know that an error occurred,

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@ internal class CancelTest : DescribeSpec({
1313
val mockWebServer = MockWebServer()
1414
val factory = NetworkResponseAdapterFactory()
1515
val retrofit = Retrofit.Builder()
16-
.baseUrl(mockWebServer.url("/"))
17-
.addConverterFactory(StringConverterFactory())
18-
.addCallAdapterFactory(factory)
19-
.build()
16+
.baseUrl(mockWebServer.url("/"))
17+
.addConverterFactory(StringConverterFactory())
18+
.addCallAdapterFactory(factory)
19+
.build()
2020

2121
describe("Cancellation") {
2222
val deferredStringType = typeOf<Deferred<NetworkResponse<String, String>>>()
23-
val adapter = factory.get(deferredStringType, emptyArray(), retrofit)!! as CallAdapter<String, Deferred<NetworkResponse<String, String>>>
2423

25-
context("Successfull call") {
24+
@Suppress("UNCHECKED_CAST")
25+
val adapter = factory.get(
26+
deferredStringType,
27+
emptyArray(),
28+
retrofit
29+
)!! as CallAdapter<String, Deferred<NetworkResponse<String, String>>>
30+
31+
context("Successful call") {
2632
val call = CompletableCall<String>()
2733
val deferred = adapter.adapt(call)
2834
call.complete("Hey")

0 commit comments

Comments
 (0)