Files
Agent-System/internal/docduty/owner_backfill_test.go
T
weichenandCursor 2f0a1b337c fix(docduty): treat assigned duty as authoritative on heal
Align document slots to project document_duty even when the wrong ID is
an active member, and fail generate/list instead of returning stale
placeholder duties. Owner author backfill now picks creator, else lowest ID.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 22:16:36 +00:00

36 lines
1.3 KiB
Go

package docduty
import "testing"
func TestPickDefaultAuthorUserID_CreatorPreferredOverLowestOwner(t *testing.T) {
members := []Member{
{UserID: 3, Status: StatusActive, ProjectRole: "owner", DocumentDuty: DutyNone},
{UserID: 10, Status: StatusActive, ProjectRole: "owner", DocumentDuty: DutyNone},
}
if got := PickDefaultAuthorUserID(members, 10); got != 10 {
t.Fatalf("creator should win over lowest owner, got %d", got)
}
}
func TestPickDefaultAuthorUserID_LowestIDWhenCreatorMissing(t *testing.T) {
members := []Member{
{UserID: 8, Status: StatusActive, ProjectRole: "owner", DocumentDuty: DutyNone},
{UserID: 3, Status: StatusActive, ProjectRole: "owner", DocumentDuty: DutyNone},
{UserID: 1, Status: StatusActive, ProjectRole: "member", DocumentDuty: DutyNone},
}
if got := PickDefaultAuthorUserID(members, 99); got != 3 {
t.Fatalf("lowest owner id, got %d", got)
}
}
func TestPickDefaultAuthorUserID_SkipsExistingDutyAndExited(t *testing.T) {
members := []Member{
{UserID: 1, Status: StatusActive, ProjectRole: "owner", DocumentDuty: DutyAuthor},
{UserID: 2, Status: "exited", ProjectRole: "owner", DocumentDuty: DutyNone},
{UserID: 4, Status: StatusActive, ProjectRole: "owner", DocumentDuty: DutyNone},
}
if got := PickDefaultAuthorUserID(members, 1); got != 4 {
t.Fatalf("existing author/exited must be skipped, got %d", got)
}
}