From 5e8ab6e12bcf8987332cbe55f393276d280bf1f1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-L8OUL9F\\gfl0034" <1003614916@qq.com> Date: Thu, 24 Sep 2026 16:23:00 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A1=A5=E6=84=8F=E8=A7=81=E5=8F=8D?= =?UTF-8?q?=E9=A6=88=E7=99=BB=E5=BD=95/=E6=B8=B8=E5=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B5=8B=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 覆盖游客缺 contact 失败与登录态 uid/app_version 回填,避免分流逻辑回归。 Co-authored-by: Cursor --- docs/daily/2026-09-24-change-list.md | 19 +++++++++++++++---- internal/module/client/logic/service_test.go | 12 ++++++++++++ internal/transport/http/auth.go | 2 +- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/docs/daily/2026-09-24-change-list.md b/docs/daily/2026-09-24-change-list.md index dffadbf..003feb0 100644 --- a/docs/daily/2026-09-24-change-list.md +++ b/docs/daily/2026-09-24-change-list.md @@ -77,7 +77,7 @@ - Spark Messenger 全页面接入检查 -<<<<<<< HEAD + ## 14:48 — 修复 make lint / make test ### 概要 @@ -121,7 +121,7 @@ ```bash make install-git-hooks # 本机只需一次 ``` -======= + ## 14:55 — 意见反馈区分登录 / 游客 ### 概要 @@ -150,10 +150,21 @@ make install-git-hooks # 本机只需一次 ### 验证 -- `make test`: skipped(按需求不跑 go test) +- `make test`: skipped(本机无 go) - 需部署并执行 migration 后生效 ### 关联 - 用户需求:意见反馈分登录与未登录 ->>>>>>> c844c07 (feat: 意见反馈支持登录与游客分流) + +## 16:25 — 反馈用例补登录路径断言 + +### 概要 + +- 补充游客缺 contact 失败、登录态写入 auth_type/uid、AppVersion Header 回填的单测断言 +- auth.go import 顺序整理 + +### 验证 + +- `make test`: skipped(本机无 go) + diff --git a/internal/module/client/logic/service_test.go b/internal/module/client/logic/service_test.go index cc4c8cc..9b5b788 100644 --- a/internal/module/client/logic/service_test.go +++ b/internal/module/client/logic/service_test.go @@ -137,6 +137,7 @@ func ctxLang(lang string) context.Context { "testing" "spark-server/internal/module/client/entity" + "spark-server/internal/pkg/reqctx" ) >>>>>>> c844c07 (feat: 意见反馈支持登录与游客分流) @@ -154,6 +155,17 @@ func TestLegalPlansFeedbackFallback(t *testing.T) { if err != nil || fb.ID == 0 || fb.AuthType != entity.FeedbackAuthGuest { t.Fatalf("feedback %+v err=%v", fb, err) } + if _, err := svc.SubmitFeedback(t.Context(), FeedbackInput{Content: "缺联系方式"}); err == nil { + t.Fatal("guest without contact should fail") + } + ctx := reqctx.With(t.Context(), &reqctx.RequestContext{UserID: 42, AppVersion: "1.2.3"}) + loginFB, err := svc.SubmitFeedback(ctx, FeedbackInput{Content: "登录用户反馈"}) + if err != nil || loginFB.AuthType != entity.FeedbackAuthLogin || loginFB.UserID == nil || *loginFB.UserID != 42 { + t.Fatalf("login feedback %+v err=%v", loginFB, err) + } + if loginFB.AppVersion != "1.2.3" { + t.Fatalf("app_version from header want 1.2.3 got %q", loginFB.AppVersion) + } } func TestClientServiceAdminAndRepo(t *testing.T) { diff --git a/internal/transport/http/auth.go b/internal/transport/http/auth.go index b7902f1..0b96ee7 100644 --- a/internal/transport/http/auth.go +++ b/internal/transport/http/auth.go @@ -8,8 +8,8 @@ import ( "github.com/gin-gonic/gin" - authlogic "spark-server/internal/module/auth/logic" authentity "spark-server/internal/module/auth/entity" + authlogic "spark-server/internal/module/auth/logic" "spark-server/internal/pkg/errs" "spark-server/internal/pkg/ratelimit" "spark-server/internal/pkg/reqctx"