MCPcopy
hub / github.com/redis/go-redis / TestConfig

Function TestConfig

maintnotifications/config_test.go:10–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestConfig(t *testing.T) {
11 t.Run("DefaultConfig", func(t *testing.T) {
12 config := DefaultConfig()
13
14 // MaxWorkers should be 0 in default config (auto-calculated)
15 if config.MaxWorkers != 0 {
16 t.Errorf("Expected MaxWorkers to be 0 (auto-calculated), got %d", config.MaxWorkers)
17 }
18
19 // HandoffQueueSize should be 0 in default config (auto-calculated)
20 if config.HandoffQueueSize != 0 {
21 t.Errorf("Expected HandoffQueueSize to be 0 (auto-calculated), got %d", config.HandoffQueueSize)
22 }
23
24 if config.RelaxedTimeout != 10*time.Second {
25 t.Errorf("Expected RelaxedTimeout to be 10s, got %v", config.RelaxedTimeout)
26 }
27
28 // Test configuration fields have proper defaults
29 if config.MaxHandoffRetries != 3 {
30 t.Errorf("Expected MaxHandoffRetries to be 3, got %d", config.MaxHandoffRetries)
31 }
32
33 // Circuit breaker defaults
34 if config.CircuitBreakerFailureThreshold != 5 {
35 t.Errorf("Expected CircuitBreakerFailureThreshold=5, got %d", config.CircuitBreakerFailureThreshold)
36 }
37 if config.CircuitBreakerResetTimeout != 60*time.Second {
38 t.Errorf("Expected CircuitBreakerResetTimeout=60s, got %v", config.CircuitBreakerResetTimeout)
39 }
40 if config.CircuitBreakerMaxRequests != 3 {
41 t.Errorf("Expected CircuitBreakerMaxRequests=3, got %d", config.CircuitBreakerMaxRequests)
42 }
43
44 if config.HandoffTimeout != 15*time.Second {
45 t.Errorf("Expected HandoffTimeout to be 15s, got %v", config.HandoffTimeout)
46 }
47
48 if config.PostHandoffRelaxedDuration != 0 {
49 t.Errorf("Expected PostHandoffRelaxedDuration to be 0 (auto-calculated), got %v", config.PostHandoffRelaxedDuration)
50 }
51
52 // Test that defaults are applied correctly
53 configWithDefaults := config.ApplyDefaultsWithPoolSize(100)
54 if configWithDefaults.PostHandoffRelaxedDuration != 20*time.Second {
55 t.Errorf("Expected PostHandoffRelaxedDuration to be 20s (2x RelaxedTimeout) after applying defaults, got %v", configWithDefaults.PostHandoffRelaxedDuration)
56 }
57 })
58
59 t.Run("ConfigValidation", func(t *testing.T) {
60 // Valid config with applied defaults
61 config := DefaultConfig().ApplyDefaults()
62 if err := config.Validate(); err != nil {
63 t.Errorf("Default config with applied defaults should be valid: %v", err)
64 }
65
66 // Invalid worker configuration (negative MaxWorkers)
67 config = &Config{

Callers

nothing calls this directly

Calls 7

DefaultConfigFunction · 0.85
ApplyDefaultsMethod · 0.80
CloneMethod · 0.65
RunMethod · 0.45
ValidateMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected