Fix production referral service wiring

Bind the referral route interface to its service and extend the module regression test to cover every route-facing operations boundary.
This commit is contained in:
Rocky
2026-08-16 21:14:50 +08:00
parent c415c53a1c
commit 676bfd2451
2 changed files with 7 additions and 1 deletions
@@ -83,6 +83,7 @@ import com.osglab.account.features.inviteweb.InviteWebConfig
import com.osglab.account.features.inviteweb.ReferralLookupPort import com.osglab.account.features.inviteweb.ReferralLookupPort
import com.osglab.account.features.inviteweb.configureInviteWebRoutes import com.osglab.account.features.inviteweb.configureInviteWebRoutes
import com.osglab.account.features.referrals.routes.referralRoutes import com.osglab.account.features.referrals.routes.referralRoutes
import com.osglab.account.features.referrals.services.ReferralOperations
import com.osglab.account.features.referrals.services.ReferralService import com.osglab.account.features.referrals.services.ReferralService
import com.osglab.account.features.referrals.services.ReferralRiskIdentity import com.osglab.account.features.referrals.services.ReferralRiskIdentity
import com.osglab.account.features.referrals.services.ReferralRiskProvider import com.osglab.account.features.referrals.services.ReferralRiskProvider
@@ -422,6 +423,7 @@ fun accountServerModule(config: AppConfig): Module = module {
bindingWindow = Duration.ofDays(config.credits.referralBindingDays), bindingWindow = Duration.ofDays(config.credits.referralBindingDays),
) )
} }
single<ReferralOperations> { get<ReferralService>() }
single<ReferralLookupPort> { single<ReferralLookupPort> {
val transactions = get<BillingTransactionRunner>() val transactions = get<BillingTransactionRunner>()
ReferralLookupPort { code -> ReferralLookupPort { code ->
@@ -5,6 +5,8 @@ import com.osglab.account.features.credits.repositories.BillingTransactionRunner
import com.osglab.account.features.credits.repositories.BillingUnitOfWork import com.osglab.account.features.credits.repositories.BillingUnitOfWork
import com.osglab.account.features.credits.services.CreditOperations import com.osglab.account.features.credits.services.CreditOperations
import com.osglab.account.features.credits.services.CreditService import com.osglab.account.features.credits.services.CreditService
import com.osglab.account.features.referrals.services.ReferralOperations
import com.osglab.account.features.referrals.services.ReferralService
import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldBe
import io.ktor.client.request.get import io.ktor.client.request.get
import io.ktor.http.HttpStatusCode import io.ktor.http.HttpStatusCode
@@ -27,7 +29,7 @@ class ApplicationTest {
} }
@Test @Test
fun `application module exposes credit operations through its interface`() { fun `application module exposes route services through their interfaces`() {
val transactionRunner = object : BillingTransactionRunner { val transactionRunner = object : BillingTransactionRunner {
override suspend fun <T> inTransaction(block: (BillingUnitOfWork) -> T): T = override suspend fun <T> inTransaction(block: (BillingUnitOfWork) -> T): T =
error("Transaction runner is not used while resolving dependencies") error("Transaction runner is not used while resolving dependencies")
@@ -41,6 +43,8 @@ class ApplicationTest {
try { try {
application.koin.get<CreditOperations>() shouldBe application.koin.get<CreditOperations>() shouldBe
application.koin.get<CreditService>() application.koin.get<CreditService>()
application.koin.get<ReferralOperations>() shouldBe
application.koin.get<ReferralService>()
} finally { } finally {
application.close() application.close()
} }