fix(test): wait for database timeout before judging fleet rollback

This commit is contained in:
2026-10-04 10:37:43 +08:00
parent 8a735020e3
commit ba4179b28c
2 changed files with 16 additions and 5 deletions
@@ -1,9 +1,15 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { validateRollbackScope, rollbackSql, buildRollbackRemoteScript, assertMidTransactionObservation, runTripRollback } from './fleet-trip-rollback-test-env.mjs'
import { validateRollbackScope, rollbackSql, buildRollbackRemoteScript, assertMidTransactionObservation, runTripRollback, requestRollbackDeparture } from './fleet-trip-rollback-test-env.mjs'
const scope={marker:'OWN_RUN',tripNo:'TR-OWN',firstCustomerId:'101',secondCustomerId:'102',firstDispatchId:'201',secondDispatchId:'202',firstOutboundId:'301',secondPalletId:'401',firstDispatchNo:'DS-OWN',expectedImage:'sha256:'+'a'.repeat(64)}
const rows=()=>[{collection:'lease',connectionId:11,lockId:'99'},{collection:'wait',requester:12,blocker:11,lockId:'99'},
{collection:'firstDispatch',id:'201',status:'DEPARTED',shipped:1},{collection:'firstOutbound',id:'301',status:'OUTBOUNDED'},{collection:'firstReplay',count:1}]
test('fault request allows database timeout and never retries an unknown write',async()=>{
const body={recordVersion:'11',idempotencyKey:'ORIGINAL'},calls=[]
const context={request:()=>{throw Error('30_SECOND_CHANNEL')},requestWithBody:async(...args)=>{calls.push(args);return {http:0,body:null}}}
assert.equal((await requestRollbackDeparture(context,'/owned/depart',body,'owned-token')).http,0)
assert.deepEqual(calls,[['POST','/owned/depart',body,'owned-token']])
})
test('plan and import are network-free; execution rejects missing TEST profile before any network',async()=>{
const plan=await runTripRollback({execute:false},{env:{}})
assert.equal(plan.businessSqlWrites,false);assert.equal(plan.deployment,false)