@@ -368,6 +368,10 @@ func TestRedisConnectionProcessor(t *testing.T) {
368
368
if err := connections [i ].MarkForHandoff ("new-endpoint:6379" , int64 (i )); err != nil {
369
369
t .Fatalf ("Failed to mark connection %d for handoff: %v" , i , err )
370
370
}
371
+ // Set a mock initialization function
372
+ connections [i ].SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
373
+ return nil
374
+ })
371
375
}
372
376
373
377
ctx := context .Background ()
@@ -450,6 +454,11 @@ func TestRedisConnectionProcessor(t *testing.T) {
450
454
t .Fatalf ("Failed to mark connection for handoff: %v" , err )
451
455
}
452
456
457
+ // Set a mock initialization function
458
+ conn .SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
459
+ return nil
460
+ })
461
+
453
462
// Process the connection to trigger handoff
454
463
shouldPool , shouldRemove , err := processor .ProcessConnectionOnPut (ctx , conn )
455
464
if err != nil {
@@ -530,6 +539,11 @@ func TestRedisConnectionProcessor(t *testing.T) {
530
539
t .Fatalf ("Failed to mark connection for handoff: %v" , err )
531
540
}
532
541
542
+ // Set a mock initialization function
543
+ conn .SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
544
+ return nil
545
+ })
546
+
533
547
// Connection should no longer be usable
534
548
if conn .IsUsable () {
535
549
t .Error ("Connection should not be usable after being marked for handoff" )
@@ -598,6 +612,10 @@ func TestRedisConnectionProcessor(t *testing.T) {
598
612
if err := conn .MarkForHandoff ("new-endpoint:6379" , int64 (i + 1 )); err != nil {
599
613
t .Fatalf ("Failed to mark connection %d for handoff: %v" , i , err )
600
614
}
615
+ // Set a mock initialization function
616
+ conn .SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
617
+ return nil
618
+ })
601
619
602
620
shouldPool , shouldRemove , err := processor .ProcessConnectionOnPut (ctx , conn )
603
621
if err != nil {
@@ -695,7 +713,14 @@ func TestRedisConnectionProcessor(t *testing.T) {
695
713
defer processor .Shutdown (context .Background ())
696
714
697
715
conn := createMockPoolConnection ()
698
- conn .MarkForHandoff ("new-endpoint:6379" , 12345 )
716
+ if err := conn .MarkForHandoff ("new-endpoint:6379" , 12345 ); err != nil {
717
+ t .Fatalf ("Failed to mark connection for handoff: %v" , err )
718
+ }
719
+
720
+ // Set a mock initialization function
721
+ conn .SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
722
+ return nil
723
+ })
699
724
700
725
ctx := context .Background ()
701
726
shouldPool , shouldRemove , err := processor .ProcessConnectionOnPut (ctx , conn )
0 commit comments