重构:硬切履约路由唯一真源
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import test from 'node:test'
|
||||
|
||||
import {
|
||||
@@ -53,15 +54,13 @@ test('渠道计划:非兜底渠道即使优先级数值更大也压过兜底
|
||||
assert.equal(plan.fallbacks[0]?.channel, 'manual')
|
||||
})
|
||||
|
||||
test('渠道计划:仅有一个兜底渠道时仍可作为实际主渠道', () => {
|
||||
test('渠道计划:只有兜底渠道时保持未路由,必须人工补主渠道', () => {
|
||||
const plan = planInternalSkuChannels([
|
||||
channel({ channel: 'manual', priority: 90, is_fallback: true }),
|
||||
])
|
||||
assert.equal(plan.primary?.channel, 'manual')
|
||||
assert.deepEqual(
|
||||
plan.attempts.map((item) => item.channel),
|
||||
['manual'],
|
||||
)
|
||||
assert.equal(plan.primary, null)
|
||||
assert.deepEqual(plan.fallbacks, [])
|
||||
assert.deepEqual(plan.attempts, [])
|
||||
})
|
||||
|
||||
test('渠道计划:历史规范化重复的同一渠道会去重,不误判为冲突', () => {
|
||||
@@ -73,3 +72,14 @@ test('渠道计划:历史规范化重复的同一渠道会去重,不误判
|
||||
assert.equal(plan.primary?.id, 2)
|
||||
assert.deepEqual(plan.conflicts, [])
|
||||
})
|
||||
|
||||
test('运行时渠道服务只读 sku_channel_routes,不再读写旧表', async () => {
|
||||
const source = await readFile(
|
||||
new URL('./internal-sku-channel-service.ts', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
assert.ok(source.includes('FROM sku_channel_routes'))
|
||||
assert.ok(source.includes('INSERT INTO sku_channel_routes'))
|
||||
assert.ok(source.includes('DELETE FROM sku_channel_routes'))
|
||||
assert.ok(!source.includes('internal_sku_channels'))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user