@@ -87,10 +87,10 @@ func TestPushNotificationRegistry(t *testing.T) {
87
87
88
88
func TestPushNotificationProcessor (t * testing.T ) {
89
89
// Test the push notification processor
90
- processor := redis .NewPushNotificationProcessor (true )
90
+ processor := redis .NewPushNotificationProcessor ()
91
91
92
- if ! processor .IsEnabled () {
93
- t .Error ("Processor should be enabled " )
92
+ if processor .GetRegistry () == nil {
93
+ t .Error ("Processor should have a registry " )
94
94
}
95
95
96
96
// Test registering handlers
@@ -124,10 +124,9 @@ func TestPushNotificationProcessor(t *testing.T) {
124
124
t .Error ("Specific handler should have been called" )
125
125
}
126
126
127
- // Test disabling processor
128
- processor .SetEnabled (false )
129
- if processor .IsEnabled () {
130
- t .Error ("Processor should be disabled" )
127
+ // Test that processor always has a registry (no enable/disable anymore)
128
+ if processor .GetRegistry () == nil {
129
+ t .Error ("Processor should always have a registry" )
131
130
}
132
131
}
133
132
@@ -146,8 +145,8 @@ func TestClientPushNotificationIntegration(t *testing.T) {
146
145
t .Error ("Push notification processor should be initialized" )
147
146
}
148
147
149
- if ! processor .IsEnabled () {
150
- t .Error ("Push notification processor should be enabled" )
148
+ if processor .GetRegistry () == nil {
149
+ t .Error ("Push notification processor should have a registry when enabled" )
151
150
}
152
151
153
152
// Test registering handlers through client
@@ -187,8 +186,9 @@ func TestClientWithoutPushNotifications(t *testing.T) {
187
186
if processor == nil {
188
187
t .Error ("Push notification processor should never be nil" )
189
188
}
190
- if processor .IsEnabled () {
191
- t .Error ("Push notification processor should be disabled when PushNotifications is false" )
189
+ // VoidPushNotificationProcessor should have nil registry
190
+ if processor .GetRegistry () != nil {
191
+ t .Error ("VoidPushNotificationProcessor should have nil registry" )
192
192
}
193
193
194
194
// Registering handlers should not panic
@@ -215,8 +215,8 @@ func TestPushNotificationEnabledClient(t *testing.T) {
215
215
t .Error ("Push notification processor should be initialized when enabled" )
216
216
}
217
217
218
- if ! processor .IsEnabled () {
219
- t .Error ("Push notification processor should be enabled" )
218
+ if processor .GetRegistry () == nil {
219
+ t .Error ("Push notification processor should have a registry when enabled" )
220
220
}
221
221
222
222
// Test registering a handler
@@ -561,10 +561,10 @@ func TestPushNotificationRegistrySpecificHandlerOnly(t *testing.T) {
561
561
562
562
func TestPushNotificationProcessorEdgeCases (t * testing.T ) {
563
563
// Test processor with disabled state
564
- processor := redis .NewPushNotificationProcessor (false )
564
+ processor := redis .NewPushNotificationProcessor ()
565
565
566
- if processor .IsEnabled () {
567
- t .Error ("Processor should be disabled " )
566
+ if processor .GetRegistry () == nil {
567
+ t .Error ("Processor should have a registry " )
568
568
}
569
569
570
570
// Test that disabled processor doesn't process notifications
@@ -587,15 +587,14 @@ func TestPushNotificationProcessorEdgeCases(t *testing.T) {
587
587
t .Error ("Handler should be called when using registry directly" )
588
588
}
589
589
590
- // Test enabling processor
591
- processor .SetEnabled (true )
592
- if ! processor .IsEnabled () {
593
- t .Error ("Processor should be enabled after SetEnabled(true)" )
590
+ // Test that processor always has a registry
591
+ if processor .GetRegistry () == nil {
592
+ t .Error ("Processor should always have a registry" )
594
593
}
595
594
}
596
595
597
596
func TestPushNotificationProcessorConvenienceMethods (t * testing.T ) {
598
- processor := redis .NewPushNotificationProcessor (true )
597
+ processor := redis .NewPushNotificationProcessor ()
599
598
600
599
// Test RegisterHandler convenience method
601
600
handlerCalled := false
@@ -822,7 +821,7 @@ func TestPushNotificationRegistryConcurrency(t *testing.T) {
822
821
823
822
func TestPushNotificationProcessorConcurrency (t * testing.T ) {
824
823
// Test thread safety of the processor
825
- processor := redis .NewPushNotificationProcessor (true )
824
+ processor := redis .NewPushNotificationProcessor ()
826
825
827
826
numGoroutines := 5
828
827
numOperations := 50
@@ -845,13 +844,7 @@ func TestPushNotificationProcessorConcurrency(t *testing.T) {
845
844
notification := []interface {}{command , "data" }
846
845
processor .GetRegistry ().HandleNotification (context .Background (), notification )
847
846
848
- // Toggle processor state occasionally
849
- if j % 20 == 0 {
850
- processor .SetEnabled (! processor .IsEnabled ())
851
- }
852
-
853
847
// Access processor state
854
- processor .IsEnabled ()
855
848
processor .GetRegistry ()
856
849
}
857
850
}(i )
@@ -898,7 +891,7 @@ func TestPushNotificationClientConcurrency(t *testing.T) {
898
891
// Access processor
899
892
processor := client .GetPushNotificationProcessor ()
900
893
if processor != nil {
901
- processor .IsEnabled ()
894
+ processor .GetRegistry ()
902
895
}
903
896
}
904
897
}(i )
@@ -929,8 +922,11 @@ func TestPushNotificationConnectionHealthCheck(t *testing.T) {
929
922
930
923
// Verify push notifications are enabled
931
924
processor := client .GetPushNotificationProcessor ()
932
- if processor == nil || ! processor .IsEnabled () {
933
- t .Fatal ("Push notifications should be enabled" )
925
+ if processor == nil {
926
+ t .Fatal ("Push notification processor should not be nil" )
927
+ }
928
+ if processor .GetRegistry () == nil {
929
+ t .Fatal ("Push notification registry should not be nil when enabled" )
934
930
}
935
931
936
932
// Register a handler for testing
@@ -959,11 +955,6 @@ func TestPushNotificationConnectionHealthCheck(t *testing.T) {
959
955
return
960
956
}
961
957
962
- if ! cn .PushNotificationProcessor .IsEnabled () {
963
- t .Error ("Push notification processor should be enabled on connection" )
964
- return
965
- }
966
-
967
958
t .Log ("✅ Connection has push notification processor correctly set" )
968
959
t .Log ("✅ Connection health check integration working correctly" )
969
960
}
0 commit comments