Add notification digests with ON CONFLICT DO UPDATE, migrations 00068-00070, supplementimpact module (analyze → confirm → claim-aware split), and wire coordinator/mutate hooks plus proposal_required digests.
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
package bizdev_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/bizdev"
|
|
"chat-agent-system/internal/docgov"
|
|
)
|
|
|
|
type stubTaskExec struct {
|
|
last bizdev.TaskRunRequest
|
|
res *bizdev.TaskRunResult
|
|
err error
|
|
}
|
|
|
|
func (s *stubTaskExec) ExecuteTask(_ context.Context, req bizdev.TaskRunRequest) (*bizdev.TaskRunResult, error) {
|
|
s.last = req
|
|
return s.res, s.err
|
|
}
|
|
|
|
func TestAfterProposalApproved_ForceEditAsAuthor(t *testing.T) {
|
|
exec := &stubTaskExec{res: &bizdev.TaskRunResult{Success: true}}
|
|
prop := &docgov.ChangeProposal{
|
|
ProposalID: "prop_1",
|
|
DocID: "doc_a",
|
|
ProjectID: 42,
|
|
Status: docgov.ProposalApprovedByAuthor,
|
|
}
|
|
res, err := bizdev.AfterProposalApproved(context.Background(), exec, prop, 9, bizdev.TaskRunRequest{
|
|
TaskKey: "feasibility_reg",
|
|
ProjectName: "P",
|
|
Backend: "stub",
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if res == nil || !res.Success {
|
|
t.Fatalf("want success result, got %+v", res)
|
|
}
|
|
if !exec.last.ForceDirectEdit {
|
|
t.Fatal("expected ForceDirectEdit=true")
|
|
}
|
|
if exec.last.UserID != 9 || exec.last.AuthorID != 9 {
|
|
t.Fatalf("want author identity 9, got user=%d author=%d", exec.last.UserID, exec.last.AuthorID)
|
|
}
|
|
if exec.last.DocID != "doc_a" || exec.last.ProjectID != 42 {
|
|
t.Fatalf("want doc/project from proposal, got doc=%s project=%d", exec.last.DocID, exec.last.ProjectID)
|
|
}
|
|
}
|
|
|
|
func TestAfterProposalApproved_NilSafe(t *testing.T) {
|
|
if _, err := bizdev.AfterProposalApproved(context.Background(), nil, &docgov.ChangeProposal{}, 1, bizdev.TaskRunRequest{}); err == nil {
|
|
t.Fatal("nil executor must error")
|
|
}
|
|
exec := &stubTaskExec{}
|
|
if _, err := bizdev.AfterProposalApproved(context.Background(), exec, nil, 1, bizdev.TaskRunRequest{}); err == nil {
|
|
t.Fatal("nil proposal must error")
|
|
}
|
|
if _, err := bizdev.AfterProposalApproved(context.Background(), exec, &docgov.ChangeProposal{DocID: "d"}, 0, bizdev.TaskRunRequest{}); err == nil {
|
|
t.Fatal("author id 0 must error")
|
|
}
|
|
}
|