fix(kbbinding): 生产保存重排待入库并按环境配对
build / build (push) Successful in 2m20s

- 生产页保存对内/对外库时,在同一事务内把还没上传、原本瞄准旧生产库的待入库项改指向新库,并在保存提示里回报迁移条数;执行已开始的项目标保持冻结。
- 重排改为「上一次生效目标 → 新目标」成对过滤:测试与生产共用 test_publications,测试侧保存不再带走瞄准生产库的待入库(验收附带发现)。
- 用例补生产重排、测试侧保存不误搬生产作业、生产保存不动测试作业三组断言。
This commit is contained in:
狐友 GXXP & LEN
2026-11-22 23:31:41 +08:00
committed by 姚章浩
parent 768ad53fe2
commit e892bfdd48
7 changed files with 201 additions and 59 deletions
+9 -4
View File
@@ -18,7 +18,8 @@ type bindingStoreFake struct {
external string
saver string
// replan records what the last save asked for, so tests can assert that the
// effective (env-fallback aware) targets were used.
// effective (env-fallback aware) targets and the previous pair were used.
replanPrevious [2]string
replanEffective [2]string
replanResult postgresstore.RoutingBindingReplanResult
replanCallCount int
@@ -33,9 +34,10 @@ func (fake *bindingStoreFake) SaveRoutingKBBindings(_ context.Context, internal,
return nil
}
func (fake *bindingStoreFake) SaveRoutingKBBindingsWithReplan(_ context.Context, internal, external, effectiveInternal, effectiveExternal, updatedBy string, _ time.Time) (postgresstore.RoutingBindingReplanResult, error) {
fake.internal, fake.external, fake.saver = internal, external, updatedBy
fake.replanEffective = [2]string{effectiveInternal, effectiveExternal}
func (fake *bindingStoreFake) SaveRoutingKBBindingsWithReplan(_ context.Context, save postgresstore.RoutingBindingSave, _ time.Time) (postgresstore.RoutingBindingReplanResult, error) {
fake.internal, fake.external, fake.saver = save.InternalID, save.ExternalID, save.UpdatedBy
fake.replanPrevious = [2]string{save.Previous.Internal, save.Previous.External}
fake.replanEffective = [2]string{save.Effective.Internal, save.Effective.External}
fake.replanCallCount++
return fake.replanResult, nil
}
@@ -134,6 +136,9 @@ func TestRoutingBindingsSaveReportsReplanAndUsesEffectiveTargets(t *testing.T) {
if store.replanEffective != [2]string{"kb-in", "env-external"} {
t.Fatalf("effective targets = %#v, want the env fallback on the unbound side", store.replanEffective)
}
if store.replanPrevious != [2]string{"env-internal", "env-external"} {
t.Fatalf("previous targets = %#v, want the pre-save effective pair", store.replanPrevious)
}
var envelope struct {
Data struct {
Replanned int `json:"replanned"`