test(library): 隔离数据契约与 r11 身份自然键矩阵
真实本机 PG/ES/MinIO:v071 目录镜像 10 模式、结构引用/游标 15 模式、 8 表×2 外部范围身份矩阵、13 模式自然键(含软删除与合法同 parent 正例)、 备份期间三注入、收尾故障与授权撤销两个真实治理 PG 用例。 需隔离服务的用例在 test-scope.json 显式声明:普通 CI 跳过不算通过。
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"knowledge-governance/internal/governance"
|
||||
"knowledge-governance/internal/jobs"
|
||||
"time"
|
||||
)
|
||||
|
||||
// In-memory API fixture mirrors dispatch shape; atomicity is tested against PG.
|
||||
func (s *fakeLibraryStore) CreateLibraryDispatch(ctx context.Context, job governance.LibraryJob, stages []string, handoff bool, now time.Time) (governance.LibraryJob, bool, error) {
|
||||
created, reused, err := s.CreateLibraryJob(ctx, job, stages, now)
|
||||
if err != nil {
|
||||
return created, reused, err
|
||||
}
|
||||
if reused && (created.State != governance.LibraryJobPending || created.QueueJobID != "") {
|
||||
return created, reused, nil
|
||||
}
|
||||
id, kind, payload, err := governance.LibraryQueueRequest(handoff, created.ID, created.Scope, created.TargetSnapshotID, "library."+string(created.Kind))
|
||||
if err != nil {
|
||||
return created, reused, err
|
||||
}
|
||||
queued, err := s.Enqueue(ctx, jobs.EnqueueRequest{ID: id, Type: kind, Payload: payload, AvailableAt: now, MaxAttempts: 1, IdempotencyKey: kind + ".queue:" + created.ID}, now)
|
||||
if err != nil {
|
||||
s.lastJob = governance.LibraryJob{}
|
||||
return governance.LibraryJob{}, false, err
|
||||
}
|
||||
if err = s.AttachLibraryQueueJob(ctx, created.ID, queued.ID, now); err != nil {
|
||||
return created, reused, err
|
||||
}
|
||||
created.QueueJobID = queued.ID
|
||||
return created, reused, nil
|
||||
}
|
||||
Reference in New Issue
Block a user