refactor(api/rest): create internal constructor for tests
This commit is contained in:
parent
db1f469a4f
commit
c7fb2817fc
2 changed files with 9 additions and 4 deletions
|
|
@ -20,7 +20,12 @@ import kotlinx.serialization.ExperimentalSerializationApi
|
|||
import moe.lava.neon.common.captcha.CaptchaRequest
|
||||
import moe.lava.neon.common.captcha.CaptchaResponse
|
||||
|
||||
class ApiClient {
|
||||
class ApiClient internal constructor(
|
||||
engine: HttpClientEngine,
|
||||
assertSuccess: Boolean,
|
||||
) {
|
||||
constructor() : this(HttpClient().engine, true)
|
||||
|
||||
private val logger = Logger.withTag("neon.core.api/client")
|
||||
|
||||
private var captchaHandler: (suspend (CaptchaRequest) -> CaptchaResponse)? = null
|
||||
|
|
@ -30,8 +35,8 @@ class ApiClient {
|
|||
}
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
internal val client = HttpClient {
|
||||
expectSuccess = true
|
||||
internal val client = HttpClient(engine) {
|
||||
expectSuccess = assertSuccess
|
||||
install(ContentNegotiation) {
|
||||
json(ApiConstants.json)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import org.koin.dsl.module
|
|||
import org.koin.plugin.module.dsl.single
|
||||
|
||||
val coreModule = module {
|
||||
single<ApiClient>()
|
||||
factory { ApiClient() }
|
||||
single<AppSettings>()
|
||||
|
||||
single<AuthRepository>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue