修复前后端逻辑并完善多数据库测试

统一仪表盘、AI 回复、卡密、扫码和通知等前后端行为,补齐并发与失败恢复测试。新增 MySQL 8.4、PostgreSQL 17 持久化 Docker 功能测试和 SQLite 脱敏播种工具。
This commit is contained in:
Christ committed 2026-07-10 14:39:13 +08:00
1 parent 45f895d0c4
commit 2f20a54f30
79 files changed
+2684 -2598

No files matched your search

+51
View File
@@ -286,6 +286,57 @@ func TestScheduleDebouncedReply_StopClearsTimers(t *testing.T) {
}
}
type cancelAwareHandler struct {
started chan struct{}
canceled chan struct{}
}
func (h *cancelAwareHandler) HandleChatMessage(ctx context.Context, _ ChatMessage) error {
close(h.started)
<-ctx.Done()
close(h.canceled)
return ctx.Err()
}
func (h *cancelAwareHandler) HandleSystemEvent(context.Context, automation.Task) error { return nil }
func (h *cancelAwareHandler) OnPasswordLoginRefresh(context.Context, string) bool { return false }
func (h *cancelAwareHandler) OnAccountAlert(context.Context, string, string, string, string) {}
func TestStopCancelsInFlightReplyHandler(t *testing.T) {
handler := &cancelAwareHandler{started: make(chan struct{}), canceled: make(chan struct{})}
acc := New(Config{CookieID: "cid", CookieStr: "unb=1", Handler: handler})
acc.reply = nil
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
acc.mu.Lock()
acc.stopFn = cancel
acc.mu.Unlock()
acc.taskMu.Lock()
acc.runtimeCtx = ctx
acc.taskMu.Unlock()
acc.scheduleDebouncedReply(ChatMessage{ChatID: "cancel-chat", SenderUserID: "buyer", Text: "hi"})
select {
case <-handler.started:
case <-time.After(MessageDebounceDelay + time.Second):
t.Fatal("handler did not start")
}
done := make(chan struct{})
go func() {
acc.Stop()
close(done)
}()
select {
case <-handler.canceled:
case <-time.After(time.Second):
t.Fatal("in-flight handler context was not canceled")
}
select {
case <-done:
case <-time.After(time.Second):
t.Fatal("Stop did not wait for handler exit")
}
}
// TestCleanupDedupLocked_ExpiredRemoved 过期消息 ID 被清理。
func TestCleanupDedupLocked_ExpiredRemoved(t *testing.T) {
acc, _, _, cleanup := newAccountForTest(t)