@@ -25,8 +25,10 @@ func NewTestHandler(name string, returnValue bool) *TestHandler {
2525 }
2626}
2727
28- func (h * TestHandler ) HandlePushNotification (ctx context.Context , notification []interface {}) bool {
28+ func (h * TestHandler ) HandlePushNotification (ctx context.Context , handlerCtx * HandlerContext , notification []interface {}) bool {
2929 h .handled = append (h .handled , notification )
30+ // Store the handler context for testing if needed
31+ _ = handlerCtx
3032 return h .returnValue
3133}
3234
@@ -131,6 +133,13 @@ func testProcessPendingNotifications(processor *Processor, ctx context.Context,
131133 return nil
132134 }
133135
136+ // Create a test handler context
137+ handlerCtx := & HandlerContext {
138+ Client : nil ,
139+ ConnPool : nil ,
140+ Conn : nil ,
141+ }
142+
134143 for {
135144 // Check if there are push notifications available
136145 replyType , err := reader .PeekReplyType ()
@@ -175,8 +184,8 @@ func testProcessPendingNotifications(processor *Processor, ctx context.Context,
175184 if notificationType , ok := notification [0 ].(string ); ok {
176185 // Get the handler for this notification type
177186 if handler := processor .registry .GetHandler (notificationType ); handler != nil {
178- // Handle the notification
179- handler .HandlePushNotification (ctx , notification )
187+ // Handle the notification with context
188+ handler .HandlePushNotification (ctx , handlerCtx , notification )
180189 }
181190 }
182191 }
@@ -420,14 +429,19 @@ func TestProcessor(t *testing.T) {
420429 ctx := context .Background ()
421430
422431 // Test with nil reader
423- err := processor .ProcessPendingNotifications (ctx , nil )
432+ handlerCtx := & HandlerContext {
433+ Client : nil ,
434+ ConnPool : nil ,
435+ Conn : nil ,
436+ }
437+ err := processor .ProcessPendingNotifications (ctx , handlerCtx , nil )
424438 if err != nil {
425439 t .Errorf ("ProcessPendingNotifications with nil reader should not error, got: %v" , err )
426440 }
427441
428442 // Test with empty reader (no buffered data)
429443 reader := proto .NewReader (strings .NewReader ("" ))
430- err = processor .ProcessPendingNotifications (ctx , reader )
444+ err = processor .ProcessPendingNotifications (ctx , handlerCtx , reader )
431445 if err != nil {
432446 t .Errorf ("ProcessPendingNotifications with empty reader should not error, got: %v" , err )
433447 }
@@ -533,21 +547,21 @@ func TestProcessor(t *testing.T) {
533547
534548 // Test the actual ProcessPendingNotifications method with real proto.Reader
535549 // Test with nil reader
536- err = processor .ProcessPendingNotifications (ctx , nil )
550+ err = processor .ProcessPendingNotifications (ctx , handlerCtx , nil )
537551 if err != nil {
538552 t .Errorf ("ProcessPendingNotifications with nil reader should not error, got: %v" , err )
539553 }
540554
541555 // Test with empty reader (no buffered data)
542556 protoReader := proto .NewReader (strings .NewReader ("" ))
543- err = processor .ProcessPendingNotifications (ctx , protoReader )
557+ err = processor .ProcessPendingNotifications (ctx , handlerCtx , protoReader )
544558 if err != nil {
545559 t .Errorf ("ProcessPendingNotifications with empty reader should not error, got: %v" , err )
546560 }
547561
548562 // Test with reader that has some data but not push notifications
549563 protoReader = proto .NewReader (strings .NewReader ("+OK\r \n " ))
550- err = processor .ProcessPendingNotifications (ctx , protoReader )
564+ err = processor .ProcessPendingNotifications (ctx , handlerCtx , protoReader )
551565 if err != nil {
552566 t .Errorf ("ProcessPendingNotifications with non-push data should not error, got: %v" , err )
553567 }
@@ -637,22 +651,27 @@ func TestVoidProcessor(t *testing.T) {
637651 t .Run ("ProcessPendingNotifications" , func (t * testing.T ) {
638652 processor := NewVoidProcessor ()
639653 ctx := context .Background ()
654+ handlerCtx := & HandlerContext {
655+ Client : nil ,
656+ ConnPool : nil ,
657+ Conn : nil ,
658+ }
640659
641660 // VoidProcessor should always succeed and do nothing
642- err := processor .ProcessPendingNotifications (ctx , nil )
661+ err := processor .ProcessPendingNotifications (ctx , handlerCtx , nil )
643662 if err != nil {
644663 t .Errorf ("VoidProcessor ProcessPendingNotifications should never error, got: %v" , err )
645664 }
646665
647666 // Test with various readers
648667 reader := proto .NewReader (strings .NewReader ("" ))
649- err = processor .ProcessPendingNotifications (ctx , reader )
668+ err = processor .ProcessPendingNotifications (ctx , handlerCtx , reader )
650669 if err != nil {
651670 t .Errorf ("VoidProcessor ProcessPendingNotifications should never error, got: %v" , err )
652671 }
653672
654673 reader = proto .NewReader (strings .NewReader ("some data" ))
655- err = processor .ProcessPendingNotifications (ctx , reader )
674+ err = processor .ProcessPendingNotifications (ctx , handlerCtx , reader )
656675 if err != nil {
657676 t .Errorf ("VoidProcessor ProcessPendingNotifications should never error, got: %v" , err )
658677 }
0 commit comments