Files
Agent-System/internal/app/docnotify/lifecycle_test.go
T
weichen 2e56ba9719 feat(docgov): complete review lifecycle gaps for lock/notify/comment/reopen
Defer locked-period supplements to a pending ledger, route duty-holder
notifications, persist stage-scoped comments, and prefer Approver for reopen.
2026-09-25 20:08:56 +00:00

48 lines
1.2 KiB
Go

package docnotify
import (
"context"
"testing"
"chat-agent-system/internal/docgov"
"chat-agent-system/internal/notification"
)
func TestRecipientForDocEvent(t *testing.T) {
doc := &docgov.DocumentRecord{AuthorID: 1, ReviewerID: 2, ApproverID: 3}
cases := []struct {
event string
want int64
}{
{notification.EventDocReviewRequested, 2},
{notification.EventDocApprovalRequested, 3},
{notification.EventDocRejected, 1},
{notification.EventDocReopened, 1},
{notification.EventDocApproved, 1},
{notification.EventDocAgentCandidateReady, 1},
}
for _, tc := range cases {
if got := RecipientForDocEvent(doc, tc.event); got != tc.want {
t.Fatalf("%s: got %d want %d", tc.event, got, tc.want)
}
}
}
func TestHandleReviewRequestedRoutesToReviewer(t *testing.T) {
n := &stubNotify{available: true}
sub := &Subscriber{
Notify: n,
Docs: stubDocs{doc: &docgov.DocumentRecord{
AuthorID: 1, ReviewerID: 7, ApproverID: 9, ProjectID: 4,
}},
}
if err := sub.Handle(context.Background(), notification.EventDocReviewRequested, map[string]any{
"doc_id": "d1",
}); err != nil {
t.Fatal(err)
}
if n.calls != 1 || n.lastType != notification.EventDocReviewRequested {
t.Fatalf("calls=%d type=%s", n.calls, n.lastType)
}
}