补齐 DocumentAccessDecider HTTP 409、projectcontext 私有对话排除统计,并更新整改 gap matrix 与测试报告。
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
package projectcontext
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/squad"
|
|
)
|
|
|
|
func TestBuildSnapshot_ConsistentForSameInput(t *testing.T) {
|
|
svc := NewService(nil)
|
|
in := BuildInput{
|
|
ProjectID: 1,
|
|
TaskKey: "system_reqs",
|
|
UserID: 1,
|
|
Facts: map[string]string{"product_type": "超声设备"},
|
|
Materials: []squad.MaterialItem{{Filename: "note.md", Content: []byte("材料说明")}},
|
|
Dialogue: []string{"项目需要 CE 认证"},
|
|
Decisions: []string{"目标市场:欧盟"},
|
|
}
|
|
s1, err := svc.BuildSnapshot(t.Context(), in)
|
|
if err != nil {
|
|
t.Fatalf("BuildSnapshot: %v", err)
|
|
}
|
|
s2, err := svc.BuildSnapshot(t.Context(), in)
|
|
if err != nil {
|
|
t.Fatalf("BuildSnapshot second: %v", err)
|
|
}
|
|
if s1.AggregateHash != s2.AggregateHash {
|
|
t.Fatalf("expected reproducible hash, got %s vs %s", s1.AggregateHash, s2.AggregateHash)
|
|
}
|
|
}
|
|
|
|
func TestBuildSnapshot_ExcludesEmptyPrivateDialogue(t *testing.T) {
|
|
svc := NewService(nil)
|
|
snap, err := svc.BuildSnapshot(t.Context(), BuildInput{
|
|
ProjectID: 2,
|
|
TaskKey: "test_manager",
|
|
Dialogue: []string{"", " ", "[private] 不应纳入", "可共享的项目讨论"},
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("BuildSnapshot: %v", err)
|
|
}
|
|
if snap.SourceCount != 1 {
|
|
t.Fatalf("expected 1 shared dialogue source, got %d", snap.SourceCount)
|
|
}
|
|
if snap.ExcludedPrivateCount < 3 {
|
|
t.Fatalf("expected excluded private count >= 3, got %d", snap.ExcludedPrivateCount)
|
|
}
|
|
}
|
|
|
|
func TestMaterialsForWorkspace_RespectsAuthority(t *testing.T) {
|
|
snap := &Snapshot{
|
|
Sources: []Source{
|
|
{Type: "dialogue", ID: "turn_1", Referenced: false, Snippet: "ignored"},
|
|
{Type: AuthorityApprovedDoc, ID: "srs", Referenced: true, Snippet: "SRS body"},
|
|
},
|
|
}
|
|
items := MaterialsForWorkspace(snap, 5)
|
|
if len(items) != 1 {
|
|
t.Fatalf("expected 1 referenced material, got %d", len(items))
|
|
}
|
|
}
|