feat: 完善代理池与抢购链路,发布 0.5.0
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user