@@ -3,6 +3,7 @@ package redis_test
33import (
44 "context"
55 "fmt"
6+ "strings"
67 "testing"
78
89 "github.com/redis/go-redis/v9"
@@ -207,12 +208,15 @@ func TestClientWithoutPushNotifications(t *testing.T) {
207208 t .Error ("VoidPushNotificationProcessor should have nil registry" )
208209 }
209210
210- // Registering handlers should not panic
211+ // Registering handlers should return an error when push notifications are disabled
211212 err := client .RegisterPushNotificationHandler ("TEST" , newTestHandler (func (ctx context.Context , notification []interface {}) bool {
212213 return true
213214 }), false )
214- if err != nil {
215- t .Errorf ("Expected nil error when processor is nil, got: %v" , err )
215+ if err == nil {
216+ t .Error ("Expected error when trying to register handler on client with disabled push notifications" )
217+ }
218+ if ! strings .Contains (err .Error (), "push notifications are disabled" ) {
219+ t .Errorf ("Expected error message about disabled push notifications, got: %v" , err )
216220 }
217221}
218222
@@ -675,19 +679,25 @@ func TestClientPushNotificationEdgeCases(t *testing.T) {
675679 })
676680 defer client .Close ()
677681
678- // These should not panic even when processor is nil and should return nil error
682+ // These should return errors when push notifications are disabled
679683 err := client .RegisterPushNotificationHandler ("TEST" , newTestHandler (func (ctx context.Context , notification []interface {}) bool {
680684 return true
681685 }), false )
682- if err != nil {
683- t .Errorf ("Expected nil error when processor is nil, got: %v" , err )
686+ if err == nil {
687+ t .Error ("Expected error when trying to register handler on client with disabled push notifications" )
688+ }
689+ if ! strings .Contains (err .Error (), "push notifications are disabled" ) {
690+ t .Errorf ("Expected error message about disabled push notifications, got: %v" , err )
684691 }
685692
686693 err = client .RegisterPushNotificationHandler ("TEST_FUNC" , newTestHandler (func (ctx context.Context , notification []interface {}) bool {
687694 return true
688695 }), false )
689- if err != nil {
690- t .Errorf ("Expected nil error when processor is nil, got: %v" , err )
696+ if err == nil {
697+ t .Error ("Expected error when trying to register handler on client with disabled push notifications" )
698+ }
699+ if ! strings .Contains (err .Error (), "push notifications are disabled" ) {
700+ t .Errorf ("Expected error message about disabled push notifications, got: %v" , err )
691701 }
692702
693703 // GetPushNotificationProcessor should return VoidPushNotificationProcessor
0 commit comments