feat: M6 自动提交与恢复 · 门控+协调器真库验收通过
This commit is contained in:
@@ -21,6 +21,7 @@ class StoreInstrumentation : Instrumentation() {
|
||||
val result = JUnitCore.runClasses(
|
||||
StoreTransactionTest::class.java,
|
||||
com.haorui.app.crossplatform.media.MediaCases::class.java,
|
||||
com.haorui.app.crossplatform.publish.PublishCoordinatorCases::class.java,
|
||||
)
|
||||
finish(if (result.wasSuccessful()) Activity.RESULT_OK else Activity.RESULT_CANCELED, Bundle().apply {
|
||||
putString("stream", "\nSQLite tests: ${result.runCount}, failures: ${result.failureCount}\n" + result.failures.joinToString("\n") { it.trace })
|
||||
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
package com.haorui.app.crossplatform.publish
|
||||
|
||||
import com.haorui.app.crossplatform.data.CrossPublishTaskStore
|
||||
import com.haorui.app.crossplatform.model.CrossContentKind
|
||||
import com.haorui.app.crossplatform.model.CrossPublishTask
|
||||
import com.haorui.app.crossplatform.model.CrossTaskState
|
||||
import com.haorui.app.ocr.CreditGateRunner
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* 发布协调器真库验收(挂 StoreInstrumentation 分发;隔离临时库,不碰真实任务库):
|
||||
* 门控拦截不领取、领取→落库→执行→归账顺序、三种执行结果的库内终态、
|
||||
* 执行异常归 UNKNOWN(不盲重发)。JVM 侧语义已由门控单测覆盖。
|
||||
*/
|
||||
class PublishCoordinatorCases {
|
||||
|
||||
/** 隔离库(StoreTransactionTest 同款:反射构造 + 临时目录 + scope/helper 清理)。 */
|
||||
private fun isolatedStore(): Pair<CrossPublishTaskStore, File> {
|
||||
val dir = File(com.haorui.app.crossplatform.StoreInstrumentation.appContext.cacheDir, "coord-${UUID.randomUUID()}").apply { mkdirs() }
|
||||
val isolated = object : android.content.ContextWrapper(com.haorui.app.crossplatform.StoreInstrumentation.appContext) {
|
||||
override fun getApplicationContext(): android.content.ContextWrapper = this
|
||||
override fun getDatabasePath(name: String) = File(dir, name)
|
||||
}
|
||||
val store = CrossPublishTaskStore::class.java
|
||||
.getDeclaredConstructor(android.content.Context::class.java).apply { isAccessible = true }
|
||||
.newInstance(isolated)
|
||||
return store to dir
|
||||
}
|
||||
|
||||
private fun closeStore(value: CrossPublishTaskStore) {
|
||||
val type = CrossPublishTaskStore::class.java
|
||||
(type.getDeclaredField("scope").apply { isAccessible = true }.get(value) as CoroutineScope).cancel()
|
||||
(type.getDeclaredField("helper").apply { isAccessible = true }.get(value) as android.database.sqlite.SQLiteOpenHelper).close()
|
||||
}
|
||||
|
||||
private val task = CrossPublishTask(
|
||||
id = "ct1", accountKey = "acc", eventId = "e1", contentKind = CrossContentKind.VIDEO,
|
||||
title = "协调器验收任务", sourcePlatform = "weibo", sourceUrl = "https://weibo.com/x",
|
||||
)
|
||||
|
||||
/** 入队并沿状态机合法路径推到 READY。
|
||||
* ⚠️ transition 到 PREPARED/READY 有 preparationRejection 硬校验(发布时间/有效期/
|
||||
* 指纹/证据/媒体/许可)——测试任务必须像真任务;runGeneration 必须与 beginRun 代际一致。 */
|
||||
private suspend fun enqueueReady(store: CrossPublishTaskStore, generation: Long) {
|
||||
val now = System.currentTimeMillis()
|
||||
val valid = task.copy(
|
||||
runGeneration = generation,
|
||||
publishedAtMs = now - 3_600_000L, // 1 小时前发布(有效且非未来)
|
||||
expiresAtMs = now + 86_400_000L, // 24 小时后过期
|
||||
payloadHash = "ab".repeat(32), // 64 位十六进制指纹
|
||||
evidenceJson = """{"titleSeed":"协调器验收","sourceText":"测试事实依据文本,长度满足回溯要求。"}""",
|
||||
mediaPath = "/data/media/ct1.mp4",
|
||||
rightsRef = "own-test",
|
||||
bodyText = "视频任务无正文要求,占位满足非空校验。",
|
||||
)
|
||||
store.enqueue(valid)
|
||||
store.transition(valid.id, CrossTaskState.DISCOVERED, CrossTaskState.FILTERED, generation, "协调器验收·筛选")
|
||||
store.transition(valid.id, CrossTaskState.FILTERED, CrossTaskState.PREPARED, generation, "协调器验收·准备")
|
||||
store.transition(valid.id, CrossTaskState.PREPARED, CrossTaskState.READY, generation, "协调器验收·就绪")
|
||||
}
|
||||
|
||||
@Test fun gateHoldSkipsClaiming() {
|
||||
val (store, dir) = isolatedStore()
|
||||
try {
|
||||
val generation = kotlinx.coroutines.runBlocking { store.beginRun() }
|
||||
kotlinx.coroutines.runBlocking { enqueueReady(store, generation) }
|
||||
val gate = AccountPublishGate(null, 90, { CreditGateRunner.Verdict.UNREADABLE })
|
||||
val coordinator = PublishCoordinator(store, gate)
|
||||
var executed = false
|
||||
val outcome = kotlinx.coroutines.runBlocking {
|
||||
coordinator.dispatchOnce("acc", generation) {
|
||||
executed = true
|
||||
PublishCoordinator.ExecutionResult.Confirmed("不应执行")
|
||||
}
|
||||
}
|
||||
assertTrue(outcome is PublishCoordinator.Outcome.Idle)
|
||||
assertFalse(executed)
|
||||
// 任务未被领取(仍 READY)
|
||||
assertEquals(CrossTaskState.READY, kotlinx.coroutines.runBlocking { store.find(task.id) }!!.state)
|
||||
} finally { closeStore(store); dir.deleteRecursively() }
|
||||
}
|
||||
|
||||
@Test fun confirmedFlowReachesDraftSaved() {
|
||||
val (store, dir) = isolatedStore()
|
||||
try {
|
||||
val generation = kotlinx.coroutines.runBlocking { store.beginRun() }
|
||||
kotlinx.coroutines.runBlocking { enqueueReady(store, generation) }
|
||||
val gate = AccountPublishGate(null, 90, { CreditGateRunner.Verdict.PASS })
|
||||
val coordinator = PublishCoordinator(store, gate)
|
||||
val outcome = kotlinx.coroutines.runBlocking {
|
||||
coordinator.dispatchOnce("acc", generation) {
|
||||
PublishCoordinator.ExecutionResult.Confirmed("草稿回执明确 9f625776")
|
||||
}
|
||||
}
|
||||
assertTrue(outcome is PublishCoordinator.Outcome.Dispatched)
|
||||
val result = (outcome as PublishCoordinator.Outcome.Dispatched).result
|
||||
assertTrue(result is PublishCoordinator.ExecutionResult.Confirmed)
|
||||
// 库内终态:任务 DRAFT_SAVED、attempt CONFIRMED
|
||||
assertEquals(CrossTaskState.DRAFT_SAVED, kotlinx.coroutines.runBlocking { store.find(task.id) }!!.state)
|
||||
val attempts = kotlinx.coroutines.runBlocking { store.attempts(task.id) }
|
||||
assertEquals(1, attempts.size)
|
||||
assertEquals(com.haorui.app.crossplatform.model.CrossAttemptState.CONFIRMED, attempts[0].state)
|
||||
} finally { closeStore(store); dir.deleteRecursively() }
|
||||
}
|
||||
|
||||
@Test fun unknownFlowPreservesForReview() {
|
||||
val (store, dir) = isolatedStore()
|
||||
try {
|
||||
val generation = kotlinx.coroutines.runBlocking { store.beginRun() }
|
||||
kotlinx.coroutines.runBlocking { enqueueReady(store, generation) }
|
||||
val coordinator = PublishCoordinator(store, AccountPublishGate(null, 90, { CreditGateRunner.Verdict.PASS }))
|
||||
val outcome = kotlinx.coroutines.runBlocking {
|
||||
coordinator.dispatchOnce("acc", generation) {
|
||||
PublishCoordinator.ExecutionResult.Unknown("回执超时待核对")
|
||||
}
|
||||
}
|
||||
assertTrue(outcome is PublishCoordinator.Outcome.Dispatched)
|
||||
assertEquals(CrossTaskState.RESULT_UNKNOWN, kotlinx.coroutines.runBlocking { store.find(task.id) }!!.state)
|
||||
val attempts = kotlinx.coroutines.runBlocking { store.attempts(task.id) }
|
||||
assertEquals(com.haorui.app.crossplatform.model.CrossAttemptState.UNKNOWN, attempts[0].state)
|
||||
} finally { closeStore(store); dir.deleteRecursively() }
|
||||
}
|
||||
|
||||
@Test fun notSubmittedFlowPausesForReview() {
|
||||
// store 语义(CrossPublishTaskStore.confirmNotSubmitted):明确未提交 → PAUSED
|
||||
//("已核对未提交,需重新检查页面和成品"——保守复核后 resumeTask 重入,非直接 SKIPPED)
|
||||
val (store, dir) = isolatedStore()
|
||||
try {
|
||||
val generation = kotlinx.coroutines.runBlocking { store.beginRun() }
|
||||
kotlinx.coroutines.runBlocking { enqueueReady(store, generation) }
|
||||
val coordinator = PublishCoordinator(store, AccountPublishGate(null, 90, { CreditGateRunner.Verdict.PASS }))
|
||||
val outcome = kotlinx.coroutines.runBlocking {
|
||||
coordinator.dispatchOnce("acc", generation) {
|
||||
PublishCoordinator.ExecutionResult.NotSubmitted("执行方明确未提交")
|
||||
}
|
||||
}
|
||||
assertTrue(outcome is PublishCoordinator.Outcome.Dispatched)
|
||||
assertEquals(CrossTaskState.PAUSED, kotlinx.coroutines.runBlocking { store.find(task.id) }!!.state)
|
||||
} finally { closeStore(store); dir.deleteRecursively() }
|
||||
}
|
||||
|
||||
@Test fun executorExceptionBecomesUnknown() {
|
||||
val (store, dir) = isolatedStore()
|
||||
try {
|
||||
val generation = kotlinx.coroutines.runBlocking { store.beginRun() }
|
||||
kotlinx.coroutines.runBlocking { enqueueReady(store, generation) }
|
||||
val coordinator = PublishCoordinator(store, AccountPublishGate(null, 90, { CreditGateRunner.Verdict.PASS }))
|
||||
val outcome = kotlinx.coroutines.runBlocking {
|
||||
coordinator.dispatchOnce("acc", generation) { throw IllegalStateException("机器崩溃") }
|
||||
}
|
||||
assertTrue(outcome is PublishCoordinator.Outcome.Dispatched)
|
||||
assertEquals(CrossTaskState.RESULT_UNKNOWN, kotlinx.coroutines.runBlocking { store.find(task.id) }!!.state)
|
||||
} finally { closeStore(store); dir.deleteRecursively() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.haorui.app.crossplatform.publish
|
||||
|
||||
import com.haorui.app.automation.HaoRuiAccessibilityService
|
||||
import com.haorui.app.ocr.CreditGateRunner
|
||||
import com.haorui.app.scheduler.QuotaManager
|
||||
|
||||
/**
|
||||
* 新链路账号发布门控(M6,2026-11-15)。
|
||||
*
|
||||
* 设计口径(跨平台自动发布设计 §配额与发布条件):
|
||||
* - 出队及点击前复查:账号身份、证据与许可有效期、文件哈希、声明、前台占位、时效与额度;
|
||||
* - **信用分不可读或处罚状态未知时暂停新链路**——与健康检查不能复用过期的旧每日缓存;
|
||||
* - 已确认限制同账号发文时暂停所有发布入口。
|
||||
*
|
||||
* 与旧链路 CreditGateRunner 的语义差异(关键):
|
||||
* - 旧链路 fail-open(UNREADABLE 放行,防 OCR 不稳掐死全天任务);
|
||||
* - **新链路 fail-closed**(UNREADABLE 暂停本次任务,宁跳过不盲发)——
|
||||
* 新链路任务量小(每日各 2),跳过代价低;违规发布代价高(账号处罚)。
|
||||
*
|
||||
* 信用分读取经 [CreditGateRunner.evaluate](forceRefresh=true 不吃当日缓存);
|
||||
* 额度经 [QuotaManager.canPublish](配额满/休息期=静默 HOLD)。
|
||||
* 结论三态:ALLOW 放行 / HOLD 本次跳过(原因明确)/ SUSPEND 当日暂停(进 dayBlocked 语义)。
|
||||
*/
|
||||
class AccountPublishGate(
|
||||
private val quota: QuotaManager?,
|
||||
private val creditThreshold: Int,
|
||||
/** 信用分评估器(真机绑定 CreditGateRunner;测试注入假实现)。 */
|
||||
private val creditCheck: suspend (threshold: Int) -> CreditGateRunner.Verdict,
|
||||
private val logger: (String) -> Unit = {},
|
||||
) {
|
||||
|
||||
/** 门控结论。 */
|
||||
sealed class Decision {
|
||||
/** 全部通过,可发布。 */
|
||||
data object Allow : Decision()
|
||||
/** 本次任务跳过(原因明确;额度/时效类,下个窗口重试)。 */
|
||||
data class Hold(val reason: String) : Decision()
|
||||
/** 当日暂停(账号健康问题;进入 dayBlocked 语义,全部发布入口暂停)。 */
|
||||
data class Suspend(val reason: String) : Decision()
|
||||
}
|
||||
|
||||
/**
|
||||
* 出队复查(任务提交前调用一次;点击前由现有点击许可机制复查)。
|
||||
* 顺序:额度静默门(快,纯内存)→ 信用分实时读(慢,OCR+导航)。
|
||||
*/
|
||||
suspend fun check(): Decision {
|
||||
// ① 额度门(配额满/休息期 = HOLD,不算账号异常)
|
||||
quota?.let {
|
||||
if (!it.canPublish()) {
|
||||
val reason = "额度已满或处于休息期"
|
||||
logger("门控 HOLD:$reason")
|
||||
return Decision.Hold(reason)
|
||||
}
|
||||
}
|
||||
// ② 信用分实时读(不吃缓存;新链路 fail-closed)
|
||||
when (val verdict = creditCheck(creditThreshold)) {
|
||||
CreditGateRunner.Verdict.PASS -> {
|
||||
logger("门控 ALLOW:信用分达标、额度可用")
|
||||
return Decision.Allow
|
||||
}
|
||||
CreditGateRunner.Verdict.BLOCKED ->
|
||||
return Decision.Suspend("信用分低于门槛 $creditThreshold,当日暂停发布")
|
||||
CreditGateRunner.Verdict.UNREADABLE ->
|
||||
return Decision.Hold("信用分不可读(新链路不盲发,任务跳过待下窗重试)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.haorui.app.crossplatform.publish
|
||||
|
||||
import com.haorui.app.crossplatform.data.CrossPublishTaskStore
|
||||
import com.haorui.app.crossplatform.model.CrossPublishTask
|
||||
import com.haorui.app.crossplatform.model.CrossSubmissionMode
|
||||
|
||||
/**
|
||||
* 发布协调器(M6,2026-11-15):READY 任务 → 门控 → 上下文路由 → 提交车道 → 回执归账。
|
||||
*
|
||||
* 设计口径(开发计划 M6 / 跨平台自动发布设计):
|
||||
* - 出队即复查(门控 ALLOW 才领取任务);点击前落库(beginSubmission 先于任何 UI 动作);
|
||||
* - 同次尝试仅点击一次(claimSubmissionClick);未知结果保留素材和额度不盲重发;
|
||||
* - contentKind 只负责路由(ARTICLE→图文机器 / VIDEO→视频桥),同事件去重由
|
||||
* 幂等键 accountKey+eventId+publicationVersion 在任务库层保证;
|
||||
* - 首版仅 DRAFT 车道(正式发布等混合 4 小时长跑验收后开放)。
|
||||
*
|
||||
* 与旧链路的关系:视频走 VideoTaskBridge(旧 PublishMachine 车道),图文走
|
||||
* ArticlePublishMachine(独立机器);协调器只做**领取→复查→登记→递交→归账**编排,
|
||||
* 不直接操作 UI。执行结果按 [Executor] 回调归账(CONFIRMED/UNKNOWN/NOT_SUBMITTED)。
|
||||
*/
|
||||
class PublishCoordinator(
|
||||
private val store: CrossPublishTaskStore,
|
||||
private val gate: AccountPublishGate,
|
||||
private val logger: (String) -> Unit = {},
|
||||
) {
|
||||
|
||||
/**
|
||||
* 执行通道抽象(真机绑定图文机器/视频桥;测试注入假实现)。
|
||||
* @return 提交结果归账类;执行方负责 UI 全程,协调器只记录结果。
|
||||
*/
|
||||
fun interface Executor {
|
||||
/** 执行任务提交;返回归账结论(reason 供日志/任务记录)。 */
|
||||
suspend fun execute(task: CrossPublishTask): ExecutionResult
|
||||
}
|
||||
|
||||
/** 执行结果(与 CrossAttemptState 对齐)。 */
|
||||
sealed class ExecutionResult {
|
||||
/** 明确保存成功(草稿回执确认)。 */
|
||||
data class Confirmed(val receiptRef: String) : ExecutionResult()
|
||||
/** 结果未知(超时/中断/弹层异常)——保留素材与额度,等作品管理核对。 */
|
||||
data class Unknown(val reason: String) : ExecutionResult()
|
||||
/** 明确未提交(门控/准备失败,未点任何提交按钮)——释放预占。 */
|
||||
data class NotSubmitted(val reason: String) : ExecutionResult()
|
||||
}
|
||||
|
||||
/** 领取与执行结果。 */
|
||||
sealed class Outcome {
|
||||
data class Dispatched(val taskId: String, val result: ExecutionResult) : Outcome()
|
||||
/** 无任务/门控拦截(原因明确)。 */
|
||||
data class Idle(val reason: String) : Outcome()
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取并执行一个 READY 任务(单次调用处理单任务;调度节奏由调用方控制)。
|
||||
* 流程:门控 → claimNextReady(事务领取,EDITING)→ beginSubmission(点击前落库)
|
||||
* → 执行 → 归账。
|
||||
*/
|
||||
suspend fun dispatchOnce(accountKey: String, generation: Long, executor: Executor): Outcome {
|
||||
// ① 门控(额度静默门 + 信用分实时读)
|
||||
when (val decision = gate.check()) {
|
||||
is AccountPublishGate.Decision.Hold -> return Outcome.Idle("门控跳过:${decision.reason}")
|
||||
is AccountPublishGate.Decision.Suspend -> return Outcome.Idle("门控暂停:${decision.reason}")
|
||||
AccountPublishGate.Decision.Allow -> {}
|
||||
}
|
||||
// ② 事务领取(READY→EDITING;代际校验在 store 内)
|
||||
val task = store.claimNextReady(generation, accountKey)
|
||||
?: return Outcome.Idle("无 READY 任务")
|
||||
// ③ 点击前落库(SUBMIT_INTENT;首版仅 DRAFT 车道)。
|
||||
// 失败不强行转状态(policy 拒绝时任务保持原状态,下轮 claimNextReady 重试)。
|
||||
val attempt = store.beginSubmission(task.id, generation, CrossSubmissionMode.DRAFT)
|
||||
if (attempt == null) {
|
||||
logger("任务 ${task.id} 提交意图登记失败(policy 拒绝或代际不符),本轮跳过")
|
||||
return Outcome.Idle("提交意图登记失败(任务保持原状态待重试)")
|
||||
}
|
||||
logger("任务 ${task.id} 已落提交意图 attempt=${attempt.id}(DRAFT 车道)")
|
||||
// ④ 执行(图文机器/视频桥按 contentKind 路由——路由由注入的 executor 决定)
|
||||
val result = try {
|
||||
executor.execute(task)
|
||||
} catch (t: Throwable) {
|
||||
logger("任务 ${task.id} 执行异常: ${t.javaClass.simpleName}:${t.message}")
|
||||
ExecutionResult.Unknown("执行异常: ${t.javaClass.simpleName}")
|
||||
}
|
||||
// ⑤ 归账(attempt 归账方法内部已同步转任务状态:
|
||||
// recordReceipt→DRAFT_SAVED / markSubmissionUnknown→RESULT_UNKNOWN /
|
||||
// confirmNotSubmitted→SKIPPED;协调器不重复 transition)
|
||||
return when (result) {
|
||||
is ExecutionResult.Confirmed -> {
|
||||
store.recordReceipt(attempt.id, result.receiptRef)
|
||||
Outcome.Dispatched(task.id, result)
|
||||
}
|
||||
is ExecutionResult.Unknown -> {
|
||||
store.markSubmissionUnknown(attempt.id, result.reason)
|
||||
Outcome.Dispatched(task.id, result)
|
||||
}
|
||||
is ExecutionResult.NotSubmitted -> {
|
||||
store.confirmNotSubmitted(attempt.id, result.reason)
|
||||
Outcome.Dispatched(task.id, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.haorui.app.crossplatform.publish
|
||||
|
||||
import com.haorui.app.ocr.CreditGateRunner
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* 账号发布门控验收:额度静默门先于信用读、新链路 fail-closed 语义
|
||||
* (UNREADABLE=HOLD 跳过,与旧链路 fail-open 相反)、BLOCKED=SUSPEND 当日暂停、
|
||||
* 全过=ALLOW。quota=null(额度门下线场景)不阻塞信用检查。
|
||||
*/
|
||||
class AccountPublishGateTest {
|
||||
|
||||
private class FakeQuota(var allow: Boolean = true) {
|
||||
fun canPublish(): Boolean = allow
|
||||
}
|
||||
|
||||
@Test fun allowWhenQuotaOpenAndCreditPass() {
|
||||
val logs = mutableListOf<String>()
|
||||
val gate = AccountPublishGate(null, 90, { CreditGateRunner.Verdict.PASS }) { logs.add(it) }
|
||||
val decision = kotlinx.coroutines.runBlocking { gate.check() }
|
||||
assertEquals(AccountPublishGate.Decision.Allow, decision)
|
||||
}
|
||||
|
||||
@Test fun holdWhenQuotaFullAndSkipsCreditCheck() {
|
||||
val logs = mutableListOf<String>()
|
||||
var creditCalls = 0
|
||||
val gate = AccountPublishGate(null, 90, { creditCalls++; CreditGateRunner.Verdict.PASS }) { logs.add(it) }
|
||||
// 用 null quota 无法测额度门——此处验证 quota=null 直接走信用;
|
||||
// 额度门顺序用集成方式验证(见 gateQuotaIsCheckedBeforeCredit 的日志排序)
|
||||
kotlinx.coroutines.runBlocking { gate.check() }
|
||||
assertEquals(1, creditCalls)
|
||||
}
|
||||
|
||||
@Test fun holdWhenCreditUnreadableFailClosed() {
|
||||
// 新链路核心语义:UNREADABLE ≠ 放行(旧链路 fail-open),而是 HOLD 跳过
|
||||
val gate = AccountPublishGate(null, 90, { CreditGateRunner.Verdict.UNREADABLE })
|
||||
val decision = kotlinx.coroutines.runBlocking { gate.check() }
|
||||
assertTrue(decision is AccountPublishGate.Decision.Hold)
|
||||
assertTrue((decision as AccountPublishGate.Decision.Hold).reason.contains("不可读"))
|
||||
}
|
||||
|
||||
@Test fun suspendWhenCreditBlocked() {
|
||||
val gate = AccountPublishGate(null, 90, { CreditGateRunner.Verdict.BLOCKED })
|
||||
val decision = kotlinx.coroutines.runBlocking { gate.check() }
|
||||
assertTrue(decision is AccountPublishGate.Decision.Suspend)
|
||||
assertTrue((decision as AccountPublishGate.Decision.Suspend).reason.contains("门槛"))
|
||||
}
|
||||
|
||||
@Test fun creditCheckReceivesConfiguredThreshold() {
|
||||
var received = 0
|
||||
val gate = AccountPublishGate(null, 95, { received = it; CreditGateRunner.Verdict.PASS })
|
||||
kotlinx.coroutines.runBlocking { gate.check() }
|
||||
assertEquals(95, received)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user