Files
digital-psychology/apps/api/internal/relation/engine_test.go
T
jackyu66gitandCursor bd22d9dddd feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具
落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-03 11:37:53 +08:00

51 lines
1.5 KiB
Go

package relation
import (
"encoding/json"
"strings"
"testing"
"time"
)
func TestBuild(t *testing.T) {
a := time.Date(1990, 1, 15, 0, 0, 0, 0, time.UTC)
b := time.Date(1992, 6, 8, 0, 0, 0, 0, time.UTC)
out := Build(a, b, "我", "TA")
if out.Summary["diff_one_liner"] == nil || out.Summary["overview"] == nil {
t.Fatal("missing summary fields")
}
dims, ok := out.Summary["dimension_compare"].([]map[string]any)
if !ok || len(dims) < 3 {
t.Fatalf("expected dimension_compare, got %#v", out.Summary["dimension_compare"])
}
secs, ok := out.Detail["sections"].([]map[string]any)
if !ok || len(secs) < 4 {
t.Fatalf("expected detail sections")
}
raw, _ := json.Marshal(out)
blob := string(raw)
for _, bad := range []string{"算命"} {
if strings.Contains(blob, bad) {
t.Fatalf("forbidden %q", bad)
}
}
if out.Summary["harmony_index"] == nil || out.Summary["star_compare"] == nil {
t.Fatal("missing match fields")
}
if out.Summary["love_index"] == nil || out.Summary["friend_index"] == nil || out.Summary["marriage_index"] == nil {
t.Fatal("missing match indices")
}
}
func TestBuildSameStyle(t *testing.T) {
d := time.Date(1990, 1, 15, 0, 0, 0, 0, time.UTC)
out := Build(d, d, "我", "TA")
if !strings.Contains(str(out.Summary["diff_one_liner"]), "接近") &&
!strings.Contains(str(out.Summary["diff_one_liner"]), "说明书") {
// same birth => same style; copy should mention 接近 or still valid
if out.Detail["weekly_practice"] == nil {
t.Fatal("missing weekly_practice")
}
}
}