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{ 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 missing mode to be allowed, got %v", errorValue) } } 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") } }