|
4 | 4 | "bytes"
|
5 | 5 | "context"
|
6 | 6 | "net"
|
| 7 | + "strings" |
7 | 8 | "testing"
|
8 | 9 | "time"
|
9 | 10 |
|
@@ -245,20 +246,26 @@ func TestConnWithoutPushNotifications(t *testing.T) {
|
245 | 246 | t.Error("VoidPushNotificationProcessor should return nil for all handlers")
|
246 | 247 | }
|
247 | 248 |
|
248 |
| - // Test RegisterPushNotificationHandler returns nil (no error) |
| 249 | + // Test RegisterPushNotificationHandler returns error when push notifications are disabled |
249 | 250 | err := conn.RegisterPushNotificationHandler("TEST", newTestHandler(func(ctx context.Context, notification []interface{}) bool {
|
250 | 251 | return true
|
251 | 252 | }), false)
|
252 |
| - if err != nil { |
253 |
| - t.Errorf("Should return nil error when no processor: %v", err) |
| 253 | + if err == nil { |
| 254 | + t.Error("Should return error when trying to register handler on connection with disabled push notifications") |
| 255 | + } |
| 256 | + if !strings.Contains(err.Error(), "push notifications are disabled") { |
| 257 | + t.Errorf("Expected error message about disabled push notifications, got: %v", err) |
254 | 258 | }
|
255 | 259 |
|
256 |
| - // Test RegisterPushNotificationHandler returns nil (no error) |
257 |
| - err = conn.RegisterPushNotificationHandler("TEST", newTestHandler(func(ctx context.Context, notification []interface{}) bool { |
| 260 | + // Test RegisterPushNotificationHandler returns error for second registration too |
| 261 | + err = conn.RegisterPushNotificationHandler("TEST2", newTestHandler(func(ctx context.Context, notification []interface{}) bool { |
258 | 262 | return true
|
259 | 263 | }), false)
|
260 |
| - if err != nil { |
261 |
| - t.Errorf("Should return nil error when no processor: %v", err) |
| 264 | + if err == nil { |
| 265 | + t.Error("Should return error when trying to register handler on connection with disabled push notifications") |
| 266 | + } |
| 267 | + if !strings.Contains(err.Error(), "push notifications are disabled") { |
| 268 | + t.Errorf("Expected error message about disabled push notifications, got: %v", err) |
262 | 269 | }
|
263 | 270 | }
|
264 | 271 |
|
|
0 commit comments