Skip to content

Commit 075b930

Browse files
committed
fix: update coverage test to expect errors for disabled push notifications
- Fix TestConnWithoutPushNotifications to expect errors instead of nil - Update test to verify error messages contain helpful information - Add strings import for error message validation - Maintain consistency with improved developer experience approach The test now correctly expects errors when trying to register handlers on connections with disabled push notifications, providing immediate feedback to developers about configuration issues rather than silent failures. This aligns with the improved developer experience where VoidProcessor returns descriptive errors instead of silently ignoring registrations.
1 parent e31987f commit 075b930

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

push_notification_coverage_test.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"net"
7+
"strings"
78
"testing"
89
"time"
910

@@ -245,20 +246,26 @@ func TestConnWithoutPushNotifications(t *testing.T) {
245246
t.Error("VoidPushNotificationProcessor should return nil for all handlers")
246247
}
247248

248-
// Test RegisterPushNotificationHandler returns nil (no error)
249+
// Test RegisterPushNotificationHandler returns error when push notifications are disabled
249250
err := conn.RegisterPushNotificationHandler("TEST", newTestHandler(func(ctx context.Context, notification []interface{}) bool {
250251
return true
251252
}), 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)
254258
}
255259

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 {
258262
return true
259263
}), 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)
262269
}
263270
}
264271

0 commit comments

Comments
 (0)