package docrevision import ( "context" "strings" "testing" ) func TestHumanRevision_ReportDoesNotClaimNoImpactWithoutIndex(t *testing.T) { svc := NewService(nil) res, err := svc.CommitHumanRevision(t.Context(), HumanRevisionRequest{ DocID: "doc-1", Markdown: "UR-001 需要记录", IdempotencyKey: "k1", ActorUserID: 1, AllowCreateBaseline: true, ProjectID: 3, }) if err != nil { t.Fatal(err) } if res.Report == nil || res.Report.Authority != ReportAuthoritative { t.Fatalf("report %#v", res.Report) } if res.Report.DeterministicFacts["coverage_status"] != ImpactIndexPending { t.Fatalf("coverage %#v", res.Report.DeterministicFacts["coverage_status"]) } for _, line := range res.Report.Summary { if strings.Contains(line, "未发现已知关联") { t.Fatal(line) } } } func TestHumanRevision_IndexedNoKnown(t *testing.T) { svc := NewService(nil) svc.CoverageResolver = func(ctx context.Context, docID string) string { return ImpactNoKnown } res, err := svc.CommitHumanRevision(t.Context(), HumanRevisionRequest{ DocID: "doc-2", Markdown: "没有条目", IdempotencyKey: "k2", ActorUserID: 1, AllowCreateBaseline: true, ProjectID: 3, }) if err != nil { t.Fatal(err) } joined := strings.Join(res.Report.Summary, " ") if !strings.Contains(joined, "未发现已知关联") { t.Fatalf("summary %s", joined) } }