Merge pull request #5906 from feeeei/main

fix(test): CN 供应商额度探测 fake 加锁消除并发 append 竞态
This commit is contained in:
Wesley Liddick
2026-08-21 17:39:03 +08:00
committed by GitHub
@@ -2,6 +2,7 @@ package service
import (
"context"
"sync"
"testing"
"github.com/Wei-Shaw/sub2api/internal/config"
@@ -14,11 +15,15 @@ import (
// - payg 账号不经过额度探测(走余额路径,本测试不放 payg 账号避免真实网络);
// - 非激活账号完全跳过。
// fakeCNQuotaProber 需要并发安全:runOnce 以 cnQuotaProbeConcurrency 并发调用 QueryUsage。
type fakeCNQuotaProber struct {
mu sync.Mutex
probed []int64
}
func (f *fakeCNQuotaProber) QueryUsage(ctx context.Context, accountID int64) (*CNProviderQuotaProbeResult, error) {
f.mu.Lock()
defer f.mu.Unlock()
f.probed = append(f.probed, accountID)
return &CNProviderQuotaProbeResult{Success: true, Persisted: true}, nil
}