24 lines
636 B
Go
24 lines
636 B
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestWithConfigAndWithLogConfig(t *testing.T) {
|
|
settings := Default()
|
|
settings.Log.Service = "orders"
|
|
settings.TrustedProxies = []string{"127.0.0.1"}
|
|
cfg := Default()
|
|
WithConfig(settings)(&cfg)
|
|
if cfg.Log.Service != "orders" || len(cfg.TrustedProxies) != 1 {
|
|
t.Fatalf("complete config was not applied: %+v", cfg)
|
|
}
|
|
settings.TrustedProxies[0] = "10.0.0.0/8"
|
|
if cfg.TrustedProxies[0] != "127.0.0.1" {
|
|
t.Fatal("WithConfig should copy trusted proxy settings")
|
|
}
|
|
|
|
WithLogConfig(Default().Log)(&cfg)
|
|
if cfg.Log.Service != "" {
|
|
t.Fatalf("log config was not replaced: %+v", cfg.Log)
|
|
}
|
|
}
|