@@ -3,6 +3,7 @@ package redis_test
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "strings"
6
7
"testing"
7
8
8
9
"github.com/redis/go-redis/v9"
@@ -207,12 +208,15 @@ func TestClientWithoutPushNotifications(t *testing.T) {
207
208
t .Error ("VoidPushNotificationProcessor should have nil registry" )
208
209
}
209
210
210
- // Registering handlers should not panic
211
+ // Registering handlers should return an error when push notifications are disabled
211
212
err := client .RegisterPushNotificationHandler ("TEST" , newTestHandler (func (ctx context.Context , notification []interface {}) bool {
212
213
return true
213
214
}), 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 )
216
220
}
217
221
}
218
222
@@ -675,19 +679,25 @@ func TestClientPushNotificationEdgeCases(t *testing.T) {
675
679
})
676
680
defer client .Close ()
677
681
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
679
683
err := client .RegisterPushNotificationHandler ("TEST" , newTestHandler (func (ctx context.Context , notification []interface {}) bool {
680
684
return true
681
685
}), 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 )
684
691
}
685
692
686
693
err = client .RegisterPushNotificationHandler ("TEST_FUNC" , newTestHandler (func (ctx context.Context , notification []interface {}) bool {
687
694
return true
688
695
}), 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 )
691
701
}
692
702
693
703
// GetPushNotificationProcessor should return VoidPushNotificationProcessor
0 commit comments