Add dbx library: PostgreSQL cluster with master/replica routing, retry, health checking
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
35
options_test.go
Normal file
35
options_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package dbx
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestApplyOptions(t *testing.T) {
|
||||
cfg := Config{}
|
||||
|
||||
logger := nopLogger{}
|
||||
metrics := &MetricsHook{}
|
||||
retry := RetryConfig{MaxAttempts: 7}
|
||||
hc := HealthCheckConfig{Interval: 10 * time.Second}
|
||||
|
||||
ApplyOptions(&cfg,
|
||||
WithLogger(logger),
|
||||
WithMetrics(metrics),
|
||||
WithRetry(retry),
|
||||
WithHealthCheck(hc),
|
||||
)
|
||||
|
||||
if cfg.Logger == nil {
|
||||
t.Error("Logger should be set")
|
||||
}
|
||||
if cfg.Metrics == nil {
|
||||
t.Error("Metrics should be set")
|
||||
}
|
||||
if cfg.Retry.MaxAttempts != 7 {
|
||||
t.Errorf("Retry.MaxAttempts = %d, want 7", cfg.Retry.MaxAttempts)
|
||||
}
|
||||
if cfg.HealthCheck.Interval != 10*time.Second {
|
||||
t.Errorf("HealthCheck.Interval = %v, want 10s", cfg.HealthCheck.Interval)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user