Files
Agent-System-Backend/eval/deliverable_test.go
T
weichen f1302ed5b3 Enable canonical versioned Go module consumption
Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements.

Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate.

Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable.

Refs: Versioned dependencies U1/U3; feature/dependency-workspace
2026-10-13 15:47:16 +00:00

63 lines
1.6 KiB
Go

// Package eval 用固定样例比较交付质量。真实会议材料放在仓外
// ~/.agent-system/eval/,或用 EVAL_DIR 指向该目录;仓内只放脱敏短样例。
package eval
import (
"os"
"path/filepath"
"testing"
"git-ssh.u1680832.nyat.app/weichen/Agent-System-Backend.git/internal/quality"
)
func TestDesensitizedSampleBeatsColumnNotes(t *testing.T) {
good := scoreFixture(t, "good.md")
bad := scoreFixture(t, "bad.md")
if !good.Passed {
t.Fatalf("good fixture should pass: %+v", good)
}
if bad.Score >= good.Score {
t.Fatalf("bad %d should be below good %d", bad.Score, good.Score)
}
missing := MissingThemes(readFixture(t, "good.md"), []string{"相关性", "标签", "未指明"})
if len(missing) > 0 {
t.Fatalf("good fixture missed themes %v", missing)
}
}
func TestExternalEvalDirOptional(t *testing.T) {
dir := os.Getenv("EVAL_DIR")
if dir == "" {
home, err := os.UserHomeDir()
if err != nil {
t.Skip(err)
}
dir = filepath.Join(home, ".agent-system", "eval")
}
entries, err := os.ReadDir(dir)
if err != nil {
t.Skip("no external eval dir")
}
for _, entry := range entries {
if entry.IsDir() || filepath.Ext(entry.Name()) != ".md" {
continue
}
report := quality.ScoreFile(filepath.Join(dir, entry.Name()))
t.Logf("%s score=%d passed=%v", entry.Name(), report.Score, report.Passed)
}
}
func scoreFixture(t *testing.T, name string) quality.Report {
t.Helper()
return quality.ScoreText(readFixture(t, name))
}
func readFixture(t *testing.T, name string) string {
t.Helper()
data, err := os.ReadFile(filepath.Join("testdata", name))
if err != nil {
t.Fatal(err)
}
return string(data)
}