refactor(api/rest): create internal constructor for tests

This commit is contained in:
Cilly Leang 2026-02-16 21:46:31 +11:00
parent db1f469a4f
commit c7fb2817fc
Signed by: cilly
GPG key ID: 6500251E087653C9
2 changed files with 9 additions and 4 deletions

View file

@ -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)
}

View file

@ -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>()