Files
Agent-System/internal/bizdev/projectcontext_inputs_test.go
T
weichen d6f5e0e28a feat(projectcontext): bizdev 注入项目对话并完成 PG 治理 E2E
新增 ctxmgr 项目对话采集并接入 PM/TE BuildSnapshot;PG 测试统一 TEST_DATABASE_URL 并使用三正式工作流 key。
2026-09-13 02:50:23 +00:00

49 lines
1.6 KiB
Go

package bizdev
import (
"context"
"testing"
"chat-agent-system/internal/ctxmgr"
"chat-agent-system/internal/projectcontext"
"chat-agent-system/internal/replyexport"
)
func TestCollectSnapshotDialogueInputs_FeedsBuildSnapshot(t *testing.T) {
ctx := context.Background()
mgr := ctxmgr.NewContextManager(nil, nil, ctxmgr.DefaultTimeDecayConfig())
projectID := int64(601)
meta := map[string]any{"project_id": projectID}
_, _ = mgr.RecordUserMessageWithID(ctx, "sess-601", 1, "user", "测试经理需要覆盖注册分类路径", "", "", meta)
_, _ = mgr.RecordUserMessageWithID(ctx, "sess-601", 1, "assistant", "我会整理测试验证范围与风险点。", "", "", map[string]any{
"project_id": projectID,
"export_policy": string(replyexport.PolicyFull),
"content_kind": string(replyexport.KindDocumentText),
})
_, _ = mgr.RecordActivity(ctx, projectID, 1, "张工", "decision", "确认先做注册分类调研", map[string]any{}, 1, true)
svc := &Service{ctxMgr: mgr}
inputs := svc.collectSnapshotDialogueInputs(ctx, projectID, 1)
if len(inputs.Dialogue) == 0 {
t.Fatalf("expected dialogue lines, got none")
}
if len(inputs.Decisions) != 1 {
t.Fatalf("expected 1 decision, got %d", len(inputs.Decisions))
}
ctxSvc := projectcontext.NewService(nil)
snap, err := ctxSvc.BuildSnapshot(ctx, projectcontext.BuildInput{
ProjectID: projectID,
TaskKey: "test_manager",
Dialogue: inputs.Dialogue,
Decisions: inputs.Decisions,
})
if err != nil {
t.Fatalf("BuildSnapshot: %v", err)
}
if snap.SourceCount < 2 {
t.Fatalf("expected dialogue + decision sources, got %d", snap.SourceCount)
}
}