fix(server/reward): TG bot 回复区分已领取/未加入两态 + 按 Telegram language_code 中英双语
ci-pangolin / Cleartext Scan — Android 禁明文 (pull_request) Successful in 24s
ci-pangolin / Portable SQL — 可移植性 (mysql/sqlite) (pull_request) Successful in 23s
ci-pangolin / Lint — shellcheck (pull_request) Successful in 6s
ci-pangolin / OpenAPI Sync Check (pull_request) Successful in 36s
ci-pangolin / Flutter — analyze + test (pull_request) Successful in 34s
ci-pangolin / Codegen Drift — token 生成物未漂移 (pull_request) Successful in 3s
ci-pangolin / DS-flow — 原型/跨端同源/代码色单源闸 (pull_request) Successful in 3s
ci-pangolin / Go — build + test (pull_request) Failing after 11s
ci-pangolin / E2E Smoke — L4 进程级端到端 (pull_request) Failing after 10s
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (pull_request) Failing after 10m52s
ci-pangolin / Go — integration (mysql/redis testcontainers) (pull_request) Failing after 4m33s
ci-pangolin / Golden — 视觉回归 (全量:components/auth/desktop/tablet) (pull_request) Failing after 19s

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9G7E3wmAYL9KeYCVZVsqu
This commit is contained in:
wangjia
2026-07-13 11:46:55 +08:00
parent 66422f92ce
commit 2c94b53a9e
3 changed files with 94 additions and 27 deletions
+31 -10
View File
@@ -25,17 +25,17 @@ func TestClaimTelegram_MemberGrantsOnce(t *testing.T) {
db := openDB(t)
seedU(t, db, 1, "u1")
s := newTgSvc(t, db, true)
ok, err := s.ClaimTelegram(context.Background(), 1, "tg-777")
if err != nil || !ok {
t.Fatalf("claim1: %v %v", ok, err)
res, err := s.ClaimTelegram(context.Background(), 1, "tg-777")
if err != nil || res != ClaimGranted {
t.Fatalf("claim1: %v %v", res, err)
}
if d := proDays(t, db, 1); d < 3 {
t.Fatalf("pro days=%d", d)
}
// 再领 → 不再发(唯一守卫)
ok2, _ := s.ClaimTelegram(context.Background(), 1, "tg-777")
if ok2 {
t.Fatalf("claimed twice")
// 再领 → 已领取过(唯一守卫),不再发
res2, err2 := s.ClaimTelegram(context.Background(), 1, "tg-777")
if err2 != nil || res2 != ClaimAlready {
t.Fatalf("claim2: %v %v", res2, err2)
}
}
@@ -43,11 +43,32 @@ func TestClaimTelegram_NonMemberNoGrant(t *testing.T) {
db := openDB(t)
seedU(t, db, 1, "u1")
s := newTgSvc(t, db, false)
ok, _ := s.ClaimTelegram(context.Background(), 1, "tg-1")
if ok {
t.Fatalf("non-member granted")
res, err := s.ClaimTelegram(context.Background(), 1, "tg-1")
if err != nil || res != ClaimNotMember {
t.Fatalf("claim: %v %v", res, err)
}
if d := proDays(t, db, 1); d >= 3 {
t.Fatalf("granted days to non-member: %d", d)
}
}
func TestTgMsgSetFor_LanguageSelection(t *testing.T) {
cases := []struct {
lang string
zh bool
}{
{"zh-hans", true},
{"zh", true},
{"zh-CN", true},
{"en", false},
{"de", false},
{"", false},
}
for _, c := range cases {
got := tgMsgSetFor(c.lang)
isZH := got.granted == tgMsgsZH.granted
if isZH != c.zh {
t.Fatalf("lang=%q: expected zh=%v, got zh=%v", c.lang, c.zh, isZH)
}
}
}