feat: 完善代理池与抢购链路,发布 0.5.0

This commit is contained in:
yml
2026-11-20 00:48:21 +08:00
parent 2f087ac7f1
commit 98b3dc4b16
28 changed files with 1522 additions and 204 deletions
+27
View File
@@ -128,3 +128,30 @@ func TestLoadConfigNormalizesAccountsPerProxy(t *testing.T) {
t.Fatalf("AccountsPerProxy=%d, want %d", got, constants.MaxAccountsPerProxy)
}
}
func TestLoadConfigNormalizesProxySparePercent(t *testing.T) {
path := filepath.Join(t.TempDir(), "config.json")
if err := os.WriteFile(path, []byte(`{"proxySparePercent":0}`), 0600); err != nil {
t.Fatal(err)
}
if got := LoadConfig(path).ProxySparePercent; got != constants.DefaultProxySparePercent {
t.Fatalf("ProxySparePercent=%d, want %d", got, constants.DefaultProxySparePercent)
}
if err := os.WriteFile(path, []byte(`{"proxySparePercent":999}`), 0600); err != nil {
t.Fatal(err)
}
if got := LoadConfig(path).ProxySparePercent; got != constants.MaxProxySparePercent {
t.Fatalf("ProxySparePercent=%d, want %d", got, constants.MaxProxySparePercent)
}
}
func TestLoadConfigMigratesLegacyTimeAPI(t *testing.T) {
path := filepath.Join(t.TempDir(), "config.json")
content := []byte(`{"timeApiUrl":"` + constants.LegacyDefaultTimeAPI + `"}`)
if err := os.WriteFile(path, content, 0600); err != nil {
t.Fatal(err)
}
if got := LoadConfig(path).TimeAPIURL; got != constants.DefaultTimeAPI {
t.Fatalf("TimeAPIURL=%q, want %q", got, constants.DefaultTimeAPI)
}
}