Files
Agent-System/internal/docrevision/commit_report_test.go
T
weichenandCursor 432884911f feat(docrevision): attach coverage status to formal human revisions
Unknown, partial, and failed coverage stay distinct from no known dependencies.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-20 15:35:07 +00:00

46 lines
1.3 KiB
Go

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)
}
}