fix: 修复反馈单测冲突残留并对齐 auth_type 接口

rebase 后 service_test 残留冲突标记,补齐 ListFeedback 筛选参数与游客 contact。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
DESKTOP-L8OUL9F\gfl0034 2026-09-24 16:25:55 +08:00
parent 5e8ab6e12b
commit 347dc191b7

View File

@ -1,7 +1,6 @@
package logic package logic
import ( import (
<<<<<<< HEAD
"context" "context"
"testing" "testing"
@ -48,8 +47,17 @@ func (s *stubClientRepo) InsertFeedback(_ context.Context, f *entity.Feedback) e
return nil return nil
} }
func (s *stubClientRepo) ListFeedback(_ context.Context, _, _ int) ([]entity.Feedback, int64, error) { func (s *stubClientRepo) ListFeedback(_ context.Context, _, _ int, authType string) ([]entity.Feedback, int64, error) {
return s.feedback, int64(len(s.feedback)), nil if authType == "" {
return s.feedback, int64(len(s.feedback)), nil
}
out := make([]entity.Feedback, 0)
for i := range s.feedback {
if s.feedback[i].AuthType == authType {
out = append(out, s.feedback[i])
}
}
return out, int64(len(out)), nil
} }
func (s *stubClientRepo) UpdateFeedbackStatus(_ context.Context, id int64, status string) error { func (s *stubClientRepo) UpdateFeedbackStatus(_ context.Context, id int64, status string) error {
@ -133,13 +141,6 @@ func (s stubOTP) AuthenticateEmail(context.Context, string, string, *userentity.
func ctxLang(lang string) context.Context { func ctxLang(lang string) context.Context {
return reqctx.With(context.Background(), &reqctx.RequestContext{Language: lang}) return reqctx.With(context.Background(), &reqctx.RequestContext{Language: lang})
} }
=======
"testing"
"spark-server/internal/module/client/entity"
"spark-server/internal/pkg/reqctx"
)
>>>>>>> c844c07 (feat: 意见反馈支持登录与游客分流)
func TestLegalPlansFeedbackFallback(t *testing.T) { func TestLegalPlansFeedbackFallback(t *testing.T) {
svc := NewService(nil, nil, nil) svc := NewService(nil, nil, nil)
@ -193,11 +194,11 @@ func TestClientServiceAdminAndRepo(t *testing.T) {
if err := svc.UpsertLegalAdmin(ctx, &entity.LegalDocument{Key: entity.DocPrivacy, Lang: "en", Title: "Privacy", Content: "body"}); err != nil { if err := svc.UpsertLegalAdmin(ctx, &entity.LegalDocument{Key: entity.DocPrivacy, Lang: "en", Title: "Privacy", Content: "body"}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
list, total, err := svc.ListFeedbackAdmin(ctx, 0, 10) list, total, err := svc.ListFeedbackAdmin(ctx, 0, 10, "")
if err != nil || total != 0 || len(list) != 0 { if err != nil || total != 0 || len(list) != 0 {
t.Fatalf("feedback list %+v %d %v", list, total, err) t.Fatalf("feedback list %+v %d %v", list, total, err)
} }
_, err = svc.SubmitFeedback(ctx, FeedbackInput{Content: "ok"}) _, err = svc.SubmitFeedback(ctx, FeedbackInput{Content: "ok feedback", Contact: "guest@example.com"})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }