Files
digital-psychology/apps/api/internal/service/home/service_test.go
T
jackyu66gitandCursor 7ab9add5dd
ci / h5 (push) Canceled after 0s
ci / api (push) Canceled after 0s
ci / ess-docs (push) Canceled after 0s
feat(ops): ECR-007 行为分析与 ECR-008 内容运营后台
落地埋点 ingest/数据看板、首页宫格 CMS 与测评上下架;含账号引导、问答流式与免责声明去重,以及 review P1 审计同事务修复。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-07 02:26:16 +08:00

31 lines
894 B
Go

package home
import "testing"
func TestNormalizeToolOK(t *testing.T) {
b := "热"
tone := "hot"
got, err := normalizeTool(ReplaceInput{
RowIndex: 1, SortOrder: 1, Path: "/portrait", Icon: "portrait", Label: "愈心解码",
Badge: &b, BadgeTone: &tone, Enabled: true,
})
if err != nil || got.Label != "愈心解码" {
t.Fatalf("got=%+v err=%v", got, err)
}
}
func TestNormalizeToolRejects(t *testing.T) {
cases := []ReplaceInput{
{RowIndex: 3, Path: "/a", Icon: "ask", Label: "x"},
{RowIndex: 1, Path: "https://evil.com", Icon: "ask", Label: "x"},
{RowIndex: 1, Path: "/../etc", Icon: "ask", Label: "x"},
{RowIndex: 1, Path: "/ask", Icon: "nope", Label: "x"},
{RowIndex: 1, Path: "/ask", Icon: "ask", Label: ""},
}
for i, c := range cases {
if _, err := normalizeTool(c); err != ErrInvalidTools {
t.Fatalf("case %d want ErrInvalidTools got %v", i, err)
}
}
}