@@ -33,6 +33,10 @@ type fakeLibraryStore struct {
|
||||
// operations/lastOperation 记录"意图身份":重放与换键的差别在这里表达(F01)。
|
||||
operations map[string]governance.LibraryOperation
|
||||
lastOperation governance.LibraryOperation
|
||||
// 续作:resumeOK/resumeErr 驱动存储层结果,resumeCalls 记录每次调用(断言不重复投递)。
|
||||
resumeOK bool
|
||||
resumeErr error
|
||||
resumeCalls []string
|
||||
}
|
||||
|
||||
func (f *fakeLibraryStore) CreateLibraryJob(_ context.Context, job governance.LibraryJob, _ []string, _ time.Time) (governance.LibraryJob, bool, error) {
|
||||
@@ -59,6 +63,11 @@ func (f *fakeLibraryStore) EnsureLibraryOperation(_ context.Context, op governan
|
||||
}
|
||||
|
||||
func (f *fakeLibraryStore) LibraryJob(_ context.Context, id string) (governance.LibraryJob, error) {
|
||||
for _, job := range f.jobs {
|
||||
if job.ID == id {
|
||||
return job, nil
|
||||
}
|
||||
}
|
||||
return governance.LibraryJob{ID: id}, nil
|
||||
}
|
||||
|
||||
@@ -178,6 +187,23 @@ func (f *fakeLibraryStore) ResetQueueJobForResume(_ context.Context, _ string, _
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResumeLibraryJob 模拟存储层事务语义:结果由 resumeResult 驱动,调用次数可断言"重复请求不重复投递"。
|
||||
func (f *fakeLibraryStore) ResumeLibraryJob(_ context.Context, jobID, queueType string, _ time.Time) (governance.LibraryJob, bool, error) {
|
||||
f.resumeCalls = append(f.resumeCalls, jobID+"/"+queueType)
|
||||
if f.resumeErr != nil {
|
||||
return governance.LibraryJob{}, false, f.resumeErr
|
||||
}
|
||||
if !f.resumeOK {
|
||||
return governance.LibraryJob{}, false, nil
|
||||
}
|
||||
for _, job := range f.jobs {
|
||||
if job.ID == jobID {
|
||||
return job, true, nil
|
||||
}
|
||||
}
|
||||
return governance.LibraryJob{}, false, nil
|
||||
}
|
||||
|
||||
func TestLibrarySyncGateRequiresEveryPieceOfEvidence(t *testing.T) {
|
||||
known := libraryKnownView{State: "known", Version: &libraryVersionView{ID: "v1"}}
|
||||
cases := []struct {
|
||||
|
||||
Reference in New Issue
Block a user