Files
digital-psychology/apps/api/internal/yijing/seed_test.go
T
jackyu66gitandCursor 13860bf1ef
ci / h5 (push) Canceled after 0s
ci / api (push) Canceled after 0s
ci / ess-docs (push) Canceled after 0s
feat(ECR-011): 昵称、首页贴士与档案 Self 唯一/合盘交叉校验
每账号仅一条 self(migration 40902);合盘只选 TA;账号昵称可改;首页穿衣/颜色/养生贴士。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-12 22:05:00 +08:00

30 lines
848 B
Go

package yijing
import (
"testing"
"time"
)
func TestSeedStableSameInputs(t *testing.T) {
bt := "10:30"
now := time.Date(2026, 8, 11, 19, 0, 0, 0, time.FixedZone("CST", 8*3600))
a := Seed("1990-05-12", &bt, now)
b := Seed("1990-05-12", &bt, now)
if a.GuaIndex != b.GuaIndex || a.GuaName != b.GuaName || a.Line != b.Line {
t.Fatalf("expected stable seed, got %+v vs %+v", a, b)
}
if a.GuaIndex < 1 || a.GuaIndex > 64 {
t.Fatalf("gua out of range: %d", a.GuaIndex)
}
}
func TestSeedChangesWithHour(t *testing.T) {
now1 := time.Date(2026, 8, 11, 9, 0, 0, 0, time.FixedZone("CST", 8*3600))
now2 := time.Date(2026, 8, 11, 18, 0, 0, 0, time.FixedZone("CST", 8*3600))
a := Seed("1990-05-12", nil, now1)
b := Seed("1990-05-12", nil, now2)
if a.DayPart == b.DayPart {
t.Fatalf("expected different day parts, both %s", a.DayPart)
}
}