go-proxy/config_runtime_test.go
Virgil b63e7562de fix(config): reject unsupported proxy modes
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 11:30:27 +00:00

39 lines
969 B
Go

package proxy
import "testing"
func TestConfig_Validate_Good(t *testing.T) {
cfg := &Config{
Mode: "nicehash",
Bind: []BindAddr{{Host: "127.0.0.1", Port: 3333}},
Pools: []PoolConfig{{URL: "pool-a:3333", Enabled: true}},
}
if errorValue := cfg.Validate(); errorValue != nil {
t.Fatalf("expected valid config, got %v", errorValue)
}
}
func TestConfig_Validate_Bad(t *testing.T) {
cfg := &Config{
Mode: "noop",
Bind: []BindAddr{{Host: "127.0.0.1", Port: 3333}},
Pools: []PoolConfig{{URL: "pool-a:3333", Enabled: true}},
}
if errorValue := cfg.Validate(); errorValue == nil {
t.Fatal("expected unsupported mode to fail validation")
}
}
func TestConfig_Validate_Ugly(t *testing.T) {
cfg := &Config{
Mode: "simple",
Bind: []BindAddr{{Host: "127.0.0.1", Port: 3333}},
Pools: []PoolConfig{{Enabled: true}},
}
if errorValue := cfg.Validate(); errorValue == nil {
t.Fatal("expected empty enabled pool URL to fail validation")
}
}