Skip to content

Commit 84f788e

Browse files
committed
fix(push): fix tests
1 parent be3a6c6 commit 84f788e

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

push/errors.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,14 @@ type ProcessorError struct {
8989
}
9090

9191
func (e *ProcessorError) Error() string {
92+
notifInfo := ""
93+
if e.PushNotificationName != "" {
94+
notifInfo = fmt.Sprintf(" for '%s'", e.PushNotificationName)
95+
}
9296
if e.Err != nil {
93-
return fmt.Sprintf("%s %s failed for '%s': %s (%v)", e.ProcessorType, e.Operation, e.PushNotificationName, e.Reason, e.Err)
97+
return fmt.Sprintf("%s %s failed%s: %s (%v)", e.ProcessorType, e.Operation, notifInfo, e.Reason, e.Err)
9498
}
95-
return fmt.Sprintf("%s %s failed for '%s': %s", e.ProcessorType, e.Operation, e.PushNotificationName, e.Reason)
99+
return fmt.Sprintf("%s %s failed%s: %s", e.ProcessorType, e.Operation, notifInfo, e.Reason)
96100
}
97101

98102
func (e *ProcessorError) Unwrap() error {

push/push_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ func NewTestHandler(name string) *TestHandler {
3232
type MockNetConn struct{}
3333

3434
func (m *MockNetConn) Read(b []byte) (n int, err error) { return 0, nil }
35-
func (m *MockNetConn) Write(b []byte) (n int, err error) { return len(b), nil }
36-
func (m *MockNetConn) Close() error { return nil }
37-
func (m *MockNetConn) LocalAddr() net.Addr { return nil }
38-
func (m *MockNetConn) RemoteAddr() net.Addr { return nil }
39-
func (m *MockNetConn) SetDeadline(t time.Time) error { return nil }
40-
func (m *MockNetConn) SetReadDeadline(t time.Time) error { return nil }
35+
func (m *MockNetConn) Write(b []byte) (n int, err error) { return len(b), nil }
36+
func (m *MockNetConn) Close() error { return nil }
37+
func (m *MockNetConn) LocalAddr() net.Addr { return nil }
38+
func (m *MockNetConn) RemoteAddr() net.Addr { return nil }
39+
func (m *MockNetConn) SetDeadline(t time.Time) error { return nil }
40+
func (m *MockNetConn) SetReadDeadline(t time.Time) error { return nil }
4141
func (m *MockNetConn) SetWriteDeadline(t time.Time) error { return nil }
4242

4343
func (h *TestHandler) HandlePushNotification(ctx context.Context, handlerCtx NotificationHandlerContext, notification []interface{}) error {
@@ -1564,7 +1564,7 @@ func TestHandlerError(t *testing.T) {
15641564
// TestProcessorError tests the ProcessorError structured error type
15651565
func TestProcessorError(t *testing.T) {
15661566
t.Run("ProcessorErrorWithoutWrappedError", func(t *testing.T) {
1567-
err := NewProcessorError("processor", "process", "invalid notification format", nil)
1567+
err := NewProcessorError("processor", "process", "", "invalid notification format", nil)
15681568

15691569
if err == nil {
15701570
t.Error("NewProcessorError should not return nil")
@@ -1594,7 +1594,7 @@ func TestProcessorError(t *testing.T) {
15941594

15951595
t.Run("ProcessorErrorWithWrappedError", func(t *testing.T) {
15961596
wrappedErr := errors.New("network error")
1597-
err := NewProcessorError("void_processor", "register", "disabled", wrappedErr)
1597+
err := NewProcessorError("void_processor", "register", "", "disabled", wrappedErr)
15981598

15991599
expectedMsg := "void_processor register failed: disabled (network error)"
16001600
if err.Error() != expectedMsg {

0 commit comments

Comments
 (0)