@@ -368,6 +368,10 @@ func TestRedisConnectionProcessor(t *testing.T) {
368368 if err := connections [i ].MarkForHandoff ("new-endpoint:6379" , int64 (i )); err != nil {
369369 t .Fatalf ("Failed to mark connection %d for handoff: %v" , i , err )
370370 }
371+ // Set a mock initialization function
372+ connections [i ].SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
373+ return nil
374+ })
371375 }
372376
373377 ctx := context .Background ()
@@ -450,6 +454,11 @@ func TestRedisConnectionProcessor(t *testing.T) {
450454 t .Fatalf ("Failed to mark connection for handoff: %v" , err )
451455 }
452456
457+ // Set a mock initialization function
458+ conn .SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
459+ return nil
460+ })
461+
453462 // Process the connection to trigger handoff
454463 shouldPool , shouldRemove , err := processor .ProcessConnectionOnPut (ctx , conn )
455464 if err != nil {
@@ -530,6 +539,11 @@ func TestRedisConnectionProcessor(t *testing.T) {
530539 t .Fatalf ("Failed to mark connection for handoff: %v" , err )
531540 }
532541
542+ // Set a mock initialization function
543+ conn .SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
544+ return nil
545+ })
546+
533547 // Connection should no longer be usable
534548 if conn .IsUsable () {
535549 t .Error ("Connection should not be usable after being marked for handoff" )
@@ -598,6 +612,10 @@ func TestRedisConnectionProcessor(t *testing.T) {
598612 if err := conn .MarkForHandoff ("new-endpoint:6379" , int64 (i + 1 )); err != nil {
599613 t .Fatalf ("Failed to mark connection %d for handoff: %v" , i , err )
600614 }
615+ // Set a mock initialization function
616+ conn .SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
617+ return nil
618+ })
601619
602620 shouldPool , shouldRemove , err := processor .ProcessConnectionOnPut (ctx , conn )
603621 if err != nil {
@@ -695,7 +713,14 @@ func TestRedisConnectionProcessor(t *testing.T) {
695713 defer processor .Shutdown (context .Background ())
696714
697715 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+ })
699724
700725 ctx := context .Background ()
701726 shouldPool , shouldRemove , err := processor .ProcessConnectionOnPut (ctx , conn )
0 commit comments