(t *testing.T)
| 237 | } |
| 238 | |
| 239 | func TestProcessorWithConfig(t *testing.T) { |
| 240 | t.Run("ProcessorUsesConfigValues", func(t *testing.T) { |
| 241 | config := &Config{ |
| 242 | MaxWorkers: 5, |
| 243 | HandoffQueueSize: 50, |
| 244 | RelaxedTimeout: 10 * time.Second, |
| 245 | HandoffTimeout: 5 * time.Second, |
| 246 | } |
| 247 | |
| 248 | baseDialer := func(ctx context.Context, network, addr string) (net.Conn, error) { |
| 249 | return &mockNetConn{addr: addr}, nil |
| 250 | } |
| 251 | |
| 252 | processor := NewPoolHook(baseDialer, "tcp", config, nil) |
| 253 | defer processor.Shutdown(context.Background()) |
| 254 | |
| 255 | // The processor should be created successfully with custom config |
| 256 | if processor == nil { |
| 257 | t.Error("Processor should be created with custom config") |
| 258 | } |
| 259 | }) |
| 260 | |
| 261 | t.Run("ProcessorWithPartialConfig", func(t *testing.T) { |
| 262 | config := &Config{ |
| 263 | MaxWorkers: 7, // Only set worker field |
| 264 | // Other fields will get defaults |
| 265 | } |
| 266 | |
| 267 | baseDialer := func(ctx context.Context, network, addr string) (net.Conn, error) { |
| 268 | return &mockNetConn{addr: addr}, nil |
| 269 | } |
| 270 | |
| 271 | processor := NewPoolHook(baseDialer, "tcp", config, nil) |
| 272 | defer processor.Shutdown(context.Background()) |
| 273 | |
| 274 | // Should work with partial config (defaults applied) |
| 275 | if processor == nil { |
| 276 | t.Error("Processor should be created with partial config") |
| 277 | } |
| 278 | }) |
| 279 | |
| 280 | t.Run("ProcessorWithNilConfig", func(t *testing.T) { |
| 281 | baseDialer := func(ctx context.Context, network, addr string) (net.Conn, error) { |
| 282 | return &mockNetConn{addr: addr}, nil |
| 283 | } |
| 284 | |
| 285 | processor := NewPoolHook(baseDialer, "tcp", nil, nil) |
| 286 | defer processor.Shutdown(context.Background()) |
| 287 | |
| 288 | // Should use default config when nil is passed |
| 289 | if processor == nil { |
| 290 | t.Error("Processor should be created with nil config (using defaults)") |
| 291 | } |
| 292 | }) |
| 293 | } |
| 294 | |
| 295 | func TestIntegrationWithApplyDefaults(t *testing.T) { |
| 296 | t.Run("ProcessorWithPartialConfigAppliesDefaults", func(t *testing.T) { |
nothing calls this directly
no test coverage detected